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(); } Link to comment https://forums.phpfreaks.com/topic/238339-ctype_alnum/ 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(); Link to comment https://forums.phpfreaks.com/topic/238339-ctype_alnum/#findComment-1224846 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? Link to comment https://forums.phpfreaks.com/topic/238339-ctype_alnum/#findComment-1224859 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 ? Link to comment https://forums.phpfreaks.com/topic/238339-ctype_alnum/#findComment-1224868 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'])) { Link to comment https://forums.phpfreaks.com/topic/238339-ctype_alnum/#findComment-1224870 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 Link to comment https://forums.phpfreaks.com/topic/238339-ctype_alnum/#findComment-1224872 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.