right now i have a form on an html page with form action to the php script page. the php page checks to make sure all the required fields were entered, and if not it will display an error message when the user submits the form. the problem is, that the error message appears on a new page, forcing the user to hit 'back' to go back and fix their mistakes.
i am looking for a way to have the errors show up right next to the required fields if left blank when they hit submit. here is a sample of how i have my error checking set up right now:
upon successful completion of the form, it will send an email to me.
Is this setup not going to work to make the errors showup next to the missing fields on the form? How can i do this with the way i have my code now? If not, how would i go about doing this at all? someone wrote this to show me how it works : http://pastebin.com/823891 but from what i understand, this wouldnt really work with how i wrote my script, because I dont ONLY check for errors, I echo the error in with die.
Any help would be great. Thanks.
i am looking for a way to have the errors show up right next to the required fields if left blank when they hit submit. here is a sample of how i have my error checking set up right now:
PHP:
$city = empty($_POST['city']) ? die ("ERROR: You must enter a city.") : stripslashes($_POST['city']);
upon successful completion of the form, it will send an email to me.
PHP:
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
if ($success){
print "Thank you ... blah blah blah";
}
else{
print "Sorry, blah blah blah";
}
Is this setup not going to work to make the errors showup next to the missing fields on the form? How can i do this with the way i have my code now? If not, how would i go about doing this at all? someone wrote this to show me how it works : http://pastebin.com/823891 but from what i understand, this wouldnt really work with how i wrote my script, because I dont ONLY check for errors, I echo the error in with die.
Any help would be great. Thanks.








