westminster86 Posted March 9, 2008 Share Posted March 9, 2008 when leaving the form blank i get the error message from the first if statment. But even when i do add values into the two fields i still get the error message? what am i doing wrong? the two varibales have values becuase ive checked with echo statments <?php $email = $_POST['uemail']; $password = $_POST['upassword']; try { if(!filled_out($_POST)) { throw new Exception('You have not filled the form out correctly - please go back and try again.'); } if(!valid_email($email)) { throw new Exception('That is not a valid email address. Please go back and try again.'); } if(strlen($password)<6) { throw new Exception('Your password must be at least 6 characters long. Please go back and try again'); } } catch (Exception $e) { echo $e->getMessage(); exit; } function filled_out($form_vars) { foreach ($form_vars as $key => $value) { if (!isset($key) || ($value == '')) return false; } return true; } function valid_email($address) { if (ereg('^[a-zA-Z0-9 \._\-]+@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z+$', $address)) return true; else return false; } ?> Link to comment https://forums.phpfreaks.com/topic/95228-validation/ Share on other sites More sharing options...
westminster86 Posted March 9, 2008 Author Share Posted March 9, 2008 ok ive solved the problem i had, now im getting errors whne trying to validate the email address. im getting: Warning: ereg() [function.ereg]: REG_EBRACK in That is not a valid email address. Please go back and try again. Link to comment https://forums.phpfreaks.com/topic/95228-validation/#findComment-487795 Share on other sites More sharing options...
westminster86 Posted March 9, 2008 Author Share Posted March 9, 2008 dnt worry i solved it. can sumone tell me, how do i make the post marked as solved? Link to comment https://forums.phpfreaks.com/topic/95228-validation/#findComment-487812 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.