I need to create a form validation system where the user will be returned to the form with the valid data still in the form and the bad data barked for correction.

Can anyone point me to a good tutorial for that sort of thing?

8 Years
Discussion Span
Last Post by silviud

Here's one way to do it:

if($_POST) {

   // create short variable names
   $name = htmlentities(trim($_POST['name']));
   $email = htmlentities(trim($_POST['email']));

   // process form
} else {

   // create short variable names
   // they should have the same names as the ones created above
   $name = NULL;
   $email = NULL;

// begin page 
<form ...>
   <input type="text" name="name" id="name" value="<?=$name?>" />
   <input type="text" name="name" id="name" value="<?=$email?>" />

Hope that helps!
- EF


i guess he want validation system...means if u typed wrong E-mail for ex. the page reload and make the E-Mail word with Red to type it agine.


Yes, but there are plenty of PHP form validation tutorials out there, plus you already offered him your code. I was simply providing a method to solve his request that "the user will be returned to the form with the valid data still in the form." :)


ahaa...got it...
BTW the form i have do that :D.. i posted the full codes and attached the needed files...check the last posts

Edited by DarkBerzerk™: n/a


Check the contact form in my cv website>> anas-tawfeek.co.cc
and try to type fake email and fake security number...if u want something like this i will post the full code for u. and the files.

It looks like your form has just what I'm looking for.

Would be very grateful if you'd post the code.



Already Posted It :) the three files codes and the ttf file (that use in the security image)...dont copy all the codes and cr8 files...coz i already uploaded them all in the end

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.