steviemac Posted June 2, 2007 Share Posted June 2, 2007 Can any one tell me why my form validation error message are not posting? Everything else in the code works fine. <? if(isset($todo) and $todo=="change-email"){ $email=mysql_real_escape_string($email); //Setting flags for checking $status = "OK"; $msg=""; if (!preg_match("/^([a-zA-Z0-9])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)+/", $_POST['email'])){ $msg=$msg."Yor E-Mail Address does not appear to be valid<BR>"; $status= "NOTOK";} if ( $email <> $email2 ){ $msg=$msg."Both email addresses are not matching<BR>"; $status= "NOTOK";} if($status<>"OK"){ echo "<p align=\"center\"><input type='button' value='Retry' onClick='history.go(-1)'></p>"; }else{ // if all validations are passed. if(mysql_query("UPDATE table set email='$email' where userName='$curUser'")){ echo "<p align=\"center\">Your email address has been successfully changed.<br>"; echo "Go back to <a href=\"index.php\"> The Members Page</a></p>"; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/53931-solved-eror-message-for-form-validation/ Share on other sites More sharing options...
AndyB Posted June 2, 2007 Share Posted June 2, 2007 Because you never echo $msg Quote Link to comment https://forums.phpfreaks.com/topic/53931-solved-eror-message-for-form-validation/#findComment-266649 Share on other sites More sharing options...
steviemac Posted June 2, 2007 Author Share Posted June 2, 2007 Isn't that what it is doing at line 6? $status = "OK"; $msg=""; Quote Link to comment https://forums.phpfreaks.com/topic/53931-solved-eror-message-for-form-validation/#findComment-266656 Share on other sites More sharing options...
penguin0 Posted June 2, 2007 Share Posted June 2, 2007 no you need to actually put echo "$msg"; where you want it to show. Quote Link to comment https://forums.phpfreaks.com/topic/53931-solved-eror-message-for-form-validation/#findComment-266659 Share on other sites More sharing options...
AndyB Posted June 2, 2007 Share Posted June 2, 2007 Isn't that what it is doing at line 6? $status = "OK"; $msg=""; All that does is define the values of the variables. Quote Link to comment https://forums.phpfreaks.com/topic/53931-solved-eror-message-for-form-validation/#findComment-266661 Share on other sites More sharing options...
steviemac Posted June 2, 2007 Author Share Posted June 2, 2007 It works by echoing the $msg Thanks for your time. I have been messing with it for two hours and finally got frustrated and decided to come here for help. Quote Link to comment https://forums.phpfreaks.com/topic/53931-solved-eror-message-for-form-validation/#findComment-266664 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.