954,174 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP Form Validation Tutorials

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?

scaiferw
Junior Poster in Training
85 posts since May 2010
Reputation Points: 25
Solved Threads: 6
 

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.

DarkBerzerk™
Light Poster
34 posts since Jul 2010
Reputation Points: 9
Solved Threads: 0
 

Here's one way to do it:

<?php
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 
?>
<html>
<head></head>
<body>
<form ...>
   <input type="text" name="name" id="name" value="<?=$name?>" />
   <input type="text" name="name" id="name" value="<?=$email?>" />
</form>
</body>
</html>


Hope that helps!
- EF

EvolutionFallen
Junior Poster
198 posts since Aug 2009
Reputation Points: 40
Solved Threads: 31
 

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.

DarkBerzerk™
Light Poster
34 posts since Jul 2010
Reputation Points: 9
Solved Threads: 0
 

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." :)

EvolutionFallen
Junior Poster
198 posts since Aug 2009
Reputation Points: 40
Solved Threads: 31
 

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

DarkBerzerk™
Light Poster
34 posts since Jul 2010
Reputation Points: 9
Solved Threads: 0
 
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.

Cheers.

scaiferw
Junior Poster in Training
85 posts since May 2010
Reputation Points: 25
Solved Threads: 6
 

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

DarkBerzerk™
Light Poster
34 posts since Jul 2010
Reputation Points: 9
Solved Threads: 0
 

BTW the post name is "Amazing Contact Form With Validation And Security Image."

DarkBerzerk™
Light Poster
34 posts since Jul 2010
Reputation Points: 9
Solved Threads: 0
 

there is complete validation for PHP form submiting.
i found following link
http://www.scriptsocean.wordpress.com

kk_pbr
Newbie Poster
7 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 
rajarajan07
Nearly a Posting Virtuoso
1,447 posts since May 2008
Reputation Points: 167
Solved Threads: 239
 

if you use php 5.2 or higher you can use the filter
http://ca3.php.net/manual/en/book.filter.php
it will validate emails, url, data type etc.

silviud
Newbie Poster
4 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You