Jump to content

handling form errors more eloquently


webguync

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/153918-handling-form-errors-more-eloquently/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.