Jump to content

Best method for parsing data between pages?


sorenchr

Recommended Posts

Hi

 

Im currently working on a login system, where visitors are able to create new users. When a visitor creates a new user, some form data is parsed to a file called docreate.php. If the form data does not comply with a set of rules(allowed characters, valid email etc.), the user is returned to the user creation page. What i want to do is to parse the correct entered data back to the users form, so that they dont have to type it in again, and, i want to give them a notification of what went wrong (bad username, username already exists etc.). Now, i've managed to rig up a system that uses sessions to do this, but it is awfully messy and i don't believe that it is the best way to do it.

 

So my question is, what would be an ideal way to parse data back to the user? I've noticed Facebook keeps your form data in a javascript string(or whatever it is called), when a user enters invalid data into their forms. But that data has to be parsed into the javascript string through something, right? And all i can think of that they are using is sessions to do this.

 

Finally, i know i could just merge the user creation page and docreate.php, but i just wanted to see here first if any of guys have experience with something that works better.

 

Best regards

Soren Christensen

Link to comment
Share on other sites

The best method is for your form and your form processing page to be the same page (the data is already present and you can simply put it back into the field values when there is an error and the form must be displayed again.) The best method if you are using two separate pages is to use session variables.

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.