Joshua F Posted November 20, 2011 Share Posted November 20, 2011 I have a field that is 30 chars max, and I have the code checking if the string is empty upon submit, though if someone were to make that field spaces only, it will allow it, and run the query and insert the data. if (strlen($_POST['title']) <= (($userhandler->getRights() == 2) ? 100000 : 30) && strlen($_POST['message']) <= (($userhandler->getRights() == 2) ? 100000 : 2000) && !empty($_POST['title']) && !empty($_POST['message']) && $userhandler->getRights() >= 0) { Link to comment https://forums.phpfreaks.com/topic/251470-disallow-space-only-string/ Share on other sites More sharing options...
Pikachu2000 Posted November 20, 2011 Share Posted November 20, 2011 trim Link to comment https://forums.phpfreaks.com/topic/251470-disallow-space-only-string/#findComment-1289683 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.