Created
May 26, 2011 05:35
-
-
Save ddliu/f86c0424202c03be8d79 to your computer and use it in GitHub Desktop.
Do an extra validation on the form data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//validate first name | |
if(strlen($form_data['first_name'])>30) | |
{ | |
die('First name too long'); | |
} | |
//validate last name | |
if(strlen($form_data['last_name'])>30) | |
{ | |
die('Last name too long'); | |
} | |
//validate email | |
if(!preg_match('#^[a-z]([a-z0-9]*[-_\.]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[\.][a-z]{2,3}([\.][a-z]{2})?$#i',$form_data['email']) | |
{ | |
die('Invalid email address'); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment