webguync Posted April 13, 2009 Share Posted April 13, 2009 I currently have my form errors set up so it displays on it's own and the user clicks on a link to get back to the login form. the code is if(mysql_num_rows($result) == 0) { // Gives an error if the username/pw given does not exist. // or if something else is wrong. echo "Please <a href='ExamLogin.php'>enter</a> your correct username and password " . mysql_error(); exit(); Ideally I would like to instead have this display on the login page and disable the action on the submit form itself if the criteria isn't met. Currently all my eval code is on the page you are being directed to after you submit. or at least do a redirect back to the login page in 10 seconds. Quote Link to comment https://forums.phpfreaks.com/topic/153918-handling-form-errors-more-eloquently/ Share on other sites More sharing options...
methodlessman Posted April 13, 2009 Share Posted April 13, 2009 Its not possible for PHP to keep a submit greyed out until the user fills out input forms properly. Only Javascript could do that for you. I don't think PHP can time-delay a redirect either. Sounds like JS only too. Quote Link to comment https://forums.phpfreaks.com/topic/153918-handling-form-errors-more-eloquently/#findComment-808944 Share on other sites More sharing options...
webguync Posted April 13, 2009 Author Share Posted April 13, 2009 thanks. it looks like I can do something like this for the redirect part. echo "<meta http-equiv='refresh' content='5; url=ExamLogin.php'>"; Quote Link to comment https://forums.phpfreaks.com/topic/153918-handling-form-errors-more-eloquently/#findComment-809004 Share on other sites More sharing options...
.josh Posted April 13, 2009 Share Posted April 13, 2009 yep. if you want the button to be grayed out, you need to use js to validate the form first. But fyi, all someone has to do is disable js and poof, no form validation. If you want to do it as a first level validation for purely aesthetic purposes, go for it. But you still need to validate form info server-side, where the user can't tamper with the validation script. Quote Link to comment https://forums.phpfreaks.com/topic/153918-handling-form-errors-more-eloquently/#findComment-809009 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.