Jump to content

contact form script on one page


jmcall10

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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.