rr77 0 Report post Posted October 12, 2007 A simple method of validation. This is good if you dont want spaces between caracters: form.php <FORM action="vali.php" method="post"> <P> <LABEL for="user">User name: </LABEL> <INPUT type="text" id="user"><BR> <INPUT type="submit" value="Send"> </P></FORM> vali.php <?php$user =$_POST['user']; $cuser=0;for($i=0; $i<strlen($user); $i++) { if ($user[$i]==" ") { $cuser=1; } } if($cuser==1){ echo "The user name have spaces";}else{ echo "The user name is correct";}?> Notice from rvalkass: Remember, all code must be placed in CODE BB tags. Thank you. Share this post Link to post Share on other sites
Stenno 0 Report post Posted October 12, 2007 <? if(preg_match("/ /", $_POST['user'])){ echo "The user name have spaces"; }else{ echo "The user name is correct"; }?> This is exactly the same result in way shorter code. Besides to remove the spaces and to set the username and password to lowercase [when you have case-insensitive login system] and to prepare them for inserting to the database just use this code:<?$username = htmlentities(strtolower(trim($_POST['user'])),ENT_QUOTES);$password = htmlentities(strtolower(trim($_POST['password'])),ENT_QUOTES);?> Share this post Link to post Share on other sites