asaraksab Posted January 21, 2009 Share Posted January 21, 2009 hi guysi got javascript validations for all the following thingsbut i need php validations for the following thingspl any one help mei have little bit idea namepasswordconfirm passwordage######emailcommentsphone numbermobile numberwith regards raksab Link to comment Share on other sites More sharing options...
justsomeguy Posted January 21, 2009 Share Posted January 21, 2009 Use the string functions:http://www.php.net/manual/en/ref.strings.phpYou can use strlen to check the length of something, you can use trim to strip spaces at the beginning and ending of a string, replace characters, etc. To check a phone number, you might want to remove spaces, parenthese, dashes, periods, etc, then make sure the remaining string is a certain number of characters. You can use is_numeric to make sure they're all numbers. You can use filter_var to check the email address.http://www.php.net/manual/en/function.filter-var.php Link to comment Share on other sites More sharing options...
sasa1985 Posted January 25, 2009 Share Posted January 25, 2009 (1)first you should check for the null values for each fieldget all the data into variables $var=$_POST['formelenetName']; you can use $_GET if method="get" in the form or $_REQUEST(this may work with both post and get) but i recommend you use form submision method as post.it is more secure. use $_POST if method="post"then check $var=""you may write a function for this or you may use big conditional check using if statement.if($var==""){print "enter a value";}check all the variable(2) validate password and confirmpassword$pass=$_POST['pass'];$cnfrpass=$_POST['cnfrpass'];if($pass==$cnfrpass){////}(3)use regular expressions to validate email,mobile number,phone numberwrite the regular expression as you write in javascript assign it to a variable $patternint ereg ( string $pattern , string $string )$string is may be email,mobile number or phone number you receive from the form submission.refer http://www.php.net/manual/en/function.ereg.php for further assistant with regular expression and ereg() function Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.