Jump to content

Using Form Validation & Preserving User's Input


phpBeginner06

Recommended Posts

I have wrote a form validation script that sends error string back to php form. My question is; what is the best way to send error strings back to orginal form, while still leaving users orginal input in form fields; while maintaining users priviate information?

 

Right now, when an error occurs; I just have a header location to send error back to forms page using query string, with variables I have already declared.

 

Example:

 

header("Location: formPage.php?nameError=$error1&emailError=$error2")

 

I know I could always catch users input in variable and send it back to form page in query string; so that it would post to user input fields, but that will leave user informtion in address bar; so that is a security risk for their priviate infomation. 

 

I also thought about sending all query strings (error & user input) throught form submission; with javascript, but I would like too try to find another way first.

 

Any one have any ideas.....

Link to comment
Share on other sites

Is there any way to send variables back to orginal form page without sending them through query string or through using another form submission to post to previous page?

 

I am not quit sure how to use sessions to send my user input values back to my orginal form and still send error query sting - I kind of understand what you are trying too tell me to do with the session, but not exactly. I still am trying to learn more about sessions; I know there like or are php cookies and I have used them before while creating a hit counter, but do not know how to implement them with this.

 

Can you give me a little bit more detail on how I can accomplish what I am trying to do with session?

Link to comment
Share on other sites

This is a variable:

$_SESSION["error"] = $string;, and you set it equal to something (info. that you wish to store)

and at the next page, where you want to retrieve the information, get it like:

$string = $_SESSION["error"];

something like this would get the information to the string again.

However, you do have to put this:

session_start();

on top of (and I mean the first thing) of your page, where you use anything like sessions to initialize the sessions.

Hope that makes it clear.

Ted

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.