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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.