Love2c0de Posted September 18, 2013 Share Posted September 18, 2013 (edited) Good evening, I have a contact form which when submitted, gets processed inside my main index.php file and inserts into the database via a separate file for my query, 2 directories above this file. When it's time to insert, we go into this file and after the query, check to see the affected rows. At the minute, I am using a header() redirect to prevent the user being able to submit data multiple times so easily with the warning message which we get. I set a $confirmation message variable in the query script which is supposed to be displayed underneath the form but because of the header() is obviously not displaying. I could always write the query script in the main index.php file but I don't think this is good for the structure and security. My only options I see here are to either redirect them to a 'Message Confirmation' page, set a session variable - but I know for sure it's not good practice to do it this way, or process the form in the index.php file but again the issues mentioned above, I will not be exploring this avenue. Any thoughts? Kind regards, L2c. Edited September 18, 2013 by Love2c0de Quote Link to comment Share on other sites More sharing options...
Solution PaulRyan Posted September 18, 2013 Solution Share Posted September 18, 2013 Put the message into a session variable, then redirect. When the redirect is complete, check to see if the message variable exists. If it does, show the message, then unset it. Quote Link to comment Share on other sites More sharing options...
Love2c0de Posted September 18, 2013 Author Share Posted September 18, 2013 Good evening PaulRyan, Did exactly that and works how I wanted it to. I was under the impression though that you shouldn't store trivial data in a session or is that completely untrue? Kind regards, L2c. Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted September 18, 2013 Share Posted September 18, 2013 (edited) I wouldn't say so, I've used that method for most for the time I've been using PHP. I stay clear of storing massive amounts of data in the session, and its fared me well up to now. Edited September 18, 2013 by PaulRyan Quote Link to comment Share on other sites More sharing options...
Love2c0de Posted September 18, 2013 Author Share Posted September 18, 2013 Thanks, I'll keep it in mind! Regards, L2c. 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.