Trium918 Posted February 11, 2008 Share Posted February 11, 2008 Do you find anything wrong with the follow script? If so, how can I improve it? <?php //<-- VALIDATE FORM ENTRY --> function valid_entry($form_vars) { foreach($form_vars as $entry) { if(empty($entry) || !ereg("^[a-zA-Z0-9]+$", $entry)) { return false; } } return true; } ?> Check the form! <?php if(isset($submit)) { // specific form variables to check // $form_vars = array($name); if(!valid_entry($_POST)) { print "invalid data!"; } else { print "valid data"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/90491-simple-question/ Share on other sites More sharing options...
Aureole Posted February 11, 2008 Share Posted February 11, 2008 I'd suggest using preg_match() as it is much faster than ereg(), other than that it looks fine. Quote Link to comment https://forums.phpfreaks.com/topic/90491-simple-question/#findComment-463962 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.