I have a script that tests variables before being entered in DB. I have two problems:
- The form submits and the entered data is lost.
There is probably a better way to do this if so let me know please.
if (!$pwd || $pwd==''){
echo "You need to enter a password.<br>
<a href=\"javascript:history.go(-1)\">Back</a>";
exit;
}
if ($pwd != $pwd1){
echo "You need to enter both passwords the same.<br>
<a href=\"javascript:history.go(-1)\">Back</a>";
exit;
}
if (!$fn || $fn==''){
echo "You need to enter a first name.<br>
<a href=\"javascript:history.go(-1)\">Back</a>";
exit;
}
if (!$ln || $ln==''){
echo "You need to enter a last name.<br>
<a href=\"javascript:history.go(-1)\">Back</a>";
exit;
}
So, you get the point. I would like to check the data and be able to return to the filled out form so the user does not have to fill out the entire form again.
- Using this simplistic method I get ALL of the warnings on a single bage with a lot of back buttons.
Is there a way to do this so each test is checked and addressed one at a time?