jmcall10 Posted May 17, 2010 Share Posted May 17, 2010 Hi guys, I was wondering if someone with good experience could help me out. Basically all I would like is a contact form script (easy I know) however there is a few requirements that I cannot find a good solution for. the requirements are as follows: script must be in one page (i.e. call itself) After the form has been submitted I would like the users variables echo'd to the user (just to show what contact info they have submitted) If after form submission the user hits refresh then I would like them to be presented with form again or something saying you have submitted a form etc I can do the first two bullet points but the third is were I am stuck and cannot see a way round it. Basically the way my script is just now, the user is initially presented with the form and after submission the form is sent via the mail function and the user is shown the info in each of the variables they submitted with a thank you. At this point if the user hits the refresh button the user is shown their info again and another submission is sent. There must be a way round this. I have tried unsetting the $_POST variables etc. If someone could either show me an example of thiers working or even guide me that would be much appreciated. However I have had many people saying "this will work" then it doesnt, because they actually didnt know if it would or not lol. That wasnt meant nasty incase it was taken that way, im just looking for a real solution or even a reason as to why this cant be done. Thanks in advance jmcall10 Quote Link to comment Share on other sites More sharing options...
jmcall10 Posted May 17, 2010 Author Share Posted May 17, 2010 Is this not possible then? Quote Link to comment Share on other sites More sharing options...
scampbell Posted May 18, 2010 Share Posted May 18, 2010 Either store the users IP in a database and disallow multiple submissions from the same IPs or set a $_SESSION var when they have submitted and only allow users with the var unset to submit. $_SESSIONS will expire. Your DB IPs will not. Quote Link to comment Share on other sites More sharing options...
jmcall10 Posted May 18, 2010 Author Share Posted May 18, 2010 scampbell, Using sessions is the solution that keeps coming up so i guess that will be my work around. Could you do me a favour. Could you post some sample code on how that might look? That would be much appreciated. jmcall10 Quote Link to comment Share on other sites More sharing options...
scampbell Posted May 18, 2010 Share Posted May 18, 2010 At the top of every page session_start(); When they have submitted $_SESSION['submitted'] = true; To check if they have submitted if ($_SESSION['submitted'] == true){ display_error(); } Quote Link to comment Share on other sites More sharing options...
jmcall10 Posted May 18, 2010 Author Share Posted May 18, 2010 This seems to be the answer! Thank you! 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.