...

View Full Version : add html to php statement



AntiHero118
05-06-2009, 09:07 PM
Hello All,

I'm trying to edit a script and I need to be able to add <a href="javascript: history.go(-1)">Go Back</a> underneath the errors that the following statement generates.


if($required_fields_check)
{

foreach($required_fields as $value){if((!isset($_REQUEST[$value]) || empty($_REQUEST[$value])) && (!isset($_FILES[$value]['name']) || empty($_FILES[$value]['name']))){$errors[] = "Please go back and complete the following $value field";}}

}else{

how would I go about adding it to this statement? echo? where do I put it?

Thanks,

- Anti

venegal
05-06-2009, 09:14 PM
We don't know what happens with that $errors array, so the only thing I'm pretty sure will work is putting the link right inside that array, like

$errors []= '<a href="javascript: history.go(-1)">Go Back</a>';
after all the other errors have been checked.

AntiHero118
05-06-2009, 09:18 PM
Sorry, I realized that I could do it with an echo.


echo "<a href=\"javascript: history.go(-1)\">Go Back</a><br /><br />";

works like a charm.

Thanks!

devinemke
05-06-2009, 09:18 PM
if ($required_fields_check)
{
foreach ($required_fields as $value)
{
if ((!isset($_REQUEST[$value]) || empty($_REQUEST[$value])) && (!isset($_FILES[$value]['name']) || empty($_FILES[$value]['name']))) {$errors[] = $value;}
}

if (isset($errors)) {echo 'Please <a href="javascript: history.go(-1)">go back</a> and complete the following fields: ' . implode(', ', $errors);}
}

AntiHero118
05-06-2009, 09:24 PM
Thanks devinemke, I just came back to post again because the link showed up on the thanks page even with no errors. your code fixed that :)

Thanks,

- Anti

AntiHero118
05-06-2009, 09:26 PM
if ($required_fields_check)
{
foreach ($required_fields as $value)
{
if ((!isset($_REQUEST[$value]) || empty($_REQUEST[$value])) && (!isset($_FILES[$value]['name']) || empty($_FILES[$value]['name']))) {$errors[] = $value;}
}

if (isset($errors)) {echo 'Please <a href="javascript: history.go(-1)">go back</a> and complete the following fields: ' . implode(', ', $errors);}
}


this works on one server, but not another?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum