Jump to content

Creating A Registration Form: Proper Way To Redirect A Bad Registration


IAmBill

Recommended Posts

Hi, I'm trying to create a very simple registration form. Nothing fancy, just a log-in, password, email address, and a couple of confirmations. While I have it set up in AJAX to alert the user if they're using a log-in or email address already in the database, I have to tend to those than don't support AJAX and redirect back to the registration page if they try to submit a registration with errors.So, the checks are easy enough... I don't have problems identifying whether or not they've made a bad registration. The issue is that I don't know the proper way to redirect the user back to the registration form if it's invalid. If I use the header() function it clears the text fields which I don't want. The second alternative is to write out the submission page as a form that writes out all of the fields with their values, then submits itself to the registration form which will then fill in the fields if the $REQUESTs are available. This seems... less than elegant, though.There are millions of registration forms all of the internet... It's a pretty common thing, which is why I'd like to do it correctly. Could anyone endulge me on what the server-side scripts look like on a registration submission?

Link to comment
Share on other sites

I always have the forms submit to themselves and check for data to automatically fill in. Check here for an example:http://w3schools.invisionzone.com/index.php?showtopic=12509
Thank you, justsomeguy.Submit to itself... it's so obvious that I can't believe I didn't think of it myself. Regardless, that link provides tons of tips that I definitely wasn't doing properly. Thanks again for everything.
Link to comment
Share on other sites

To be fair justsomeguy's script still manually inserts the form values from the previous submission attempt in each field value, so that still has to happen. It's still simpler than the way I do it at present which is to post the form to a separate handler and set the various values to the session if I need to redirect the user back to the form. I may well change that as it does mean I've got a bunch of session variables that I don't have a great deal of further need for. That said, while setting the values to session variables means more code, now that I've done it it means more work to change it. Much of a muchness I suppose.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...