E-mail submission page - re-sends data when page reloads/refreshes.
Ok, well ive posted quite a lot of code (excluding the html which is unnessisary for my problem), but this code is for my home page which has a mailing list submission form, which works fine.... nearly.
It all works apart from when you submit a valid e-mail address and then refresh or re-visit the page, where it posts the e-mail adress you submitted again as the page is loading.
- perhaps the form/page needs resetting somehow...??
Its a bit of a challenge but could anyone solve the problem. Any help will be much appriciated, thanks.
$value = 'Your E-mail address';
$value = $_POST['Email'];
// get posted data into local variables
$EmailTo = "firstname.lastname@example.org";
$Subject = "Mailing list";
$Email = Trim(stripslashes($_POST['Email']));
// prepare email body text
$Body = "";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
You are not making any sense! You keep asking for different things. You said: 'It all works apart from when you submit a valid e-mail address and then refresh or re-visit the page where it posts the e-mail adress you submitted again as the page is loading'. Now you are saying you want that to happen. And why would you want to display the form once the client has done the submission?
Well i don't nessiseraly want the same person to be able to sign up using the same e-mail address, its just that if more than one person wanted to use the same browser they would not be able to sign up as the other person already has done so (unless they revisit the site, clearing the stored email data)
I want the form to be displayed all the time as it is part of the website layout.
It might be a better idea for the code to write to a txt file creating a list of e-mail addreses when a subscribe radio button is selected. Then if someone signs up with the same email it could cheack the txt file for the same email, also it could delete email address when the person selects a radio button unsubscribe. - might be to hard, i duno
And secondly let me assure you ... that I am a complete beginner.
Ya right LOL aren't we all
As for your form thing. As Bokeh said that is a browser issue. The browser is storing the info.
You could store that info in a txt file, but I believe that if you have access to a database that would be much much much better! txt files can get unwieldly after awhile.
You could also think about setting a session variable so that when the form is submitted it processes it then destroy the session variable upon a successful submission so that when someone refreshes the page or goes back they will only see the original form. This will not stop them from refilling out the form and submitting it though.
This is how the code looks withe the added code:
(this is the webpage with the form on: www.theparoles.co.uk/index2.php)
echo "alert(\"Thank you for singing up to our mailing list.\");";