sofia403 Posted June 3, 2011 Share Posted June 3, 2011 I'm trying to make it so that the username in registration form is only alphanumeric. i have that code below, but it still passes through all the special characters. is there a mistake im making someplace? thanks if( empty($_POST['name'])){ header("Location:Messages.php?msg=3"); exit(); } elseif (ctype_alnum($_POST['name'])) { header( "Location:Messages.php?msg=26" ); exit(); } Quote Link to comment Share on other sites More sharing options...
fugix Posted June 3, 2011 Share Posted June 3, 2011 elseif (ctype_alnum($_POST['name']) == TRUE) { header( "Location:Messages.php?msg=26" ); exit(); Quote Link to comment Share on other sites More sharing options...
sofia403 Posted June 3, 2011 Author Share Posted June 3, 2011 thanks fugix, but it still lets this characters pass through %$'" ' any ideas? Quote Link to comment Share on other sites More sharing options...
fugix Posted June 3, 2011 Share Posted June 3, 2011 so even if it isnt a true alnum it is still directing you to Messages.php?msg=26 ? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted June 3, 2011 Share Posted June 3, 2011 Try this: elseif (!ctype_alnum($_POST['name'])) { Quote Link to comment Share on other sites More sharing options...
sofia403 Posted June 3, 2011 Author Share Posted June 3, 2011 elseif (!ctype_alnum($_POST['name'])) { ^^^^^^^^^^^^^^ that worked! thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.