phpBeginner06 Posted February 19, 2007 Share Posted February 19, 2007 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..... Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted February 19, 2007 Share Posted February 19, 2007 use sessions, try: $_SESSION["error"] = "$error1"; however, this: session_start(); must be on top of all the pages. Ted Quote Link to comment Share on other sites More sharing options...
phpBeginner06 Posted February 19, 2007 Author Share Posted February 19, 2007 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? Quote Link to comment Share on other sites More sharing options...
ted_chou12 Posted February 19, 2007 Share Posted February 19, 2007 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 Quote Link to comment Share on other sites More sharing options...
phpBeginner06 Posted February 19, 2007 Author Share Posted February 19, 2007 Thanks Ted - I will give it a try. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.