Ninjakreborn Posted April 17, 2007 Share Posted April 17, 2007 I have the following form (as an example) <?php // this section is for the mailing list. // first check if anything was submitted if (isset($_POST['submit']) && $_POST['submit'] == "Subscribe") { if ($_POST['email'] == "") { // error check email echo "Email Required"; echo "<br />"; $show = "yes"; }else { // subscribe if everything is right $email = mysql_real_escape_string($_POST['email']); $insert = "INSERT INTO mlm_users (email) VALUES ('$email');"; if (mysql_query($insert)) { echo "Subscribed<br />"; }else { echo "Problem subscribing please try again later.<br />"; } $show = "no"; // this will stop the form from showing } }elseif (isset($_POST['submit']) && $_POST['submit'] == "Un-Subscribe") { if ($_POST['email'] == "") { echo "Email Required"; echo "<br />"; $show = "yes"; }else { $email = mysql_real_escape_string($_POST['email']); $insert = "DELETE FROM mlm_users WHERE email = '$email';"; if (mysql_query($insert)) { echo "Un-Subscribed<br />"; }else { echo "Problem subscribing please try again later.<br />"; } $show = "no"; } } if ($show != "no") { ?> <div style="float:right;"><strong><br>Sign up for the inside scoop on special <br>promotions, contests, and exclusive <br>bonuses for our members.</strong><br> <form name="subscription" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <strong>Email:</strong> <input type="email" name="email" value="" /><br /><input type="submit" name="submit" value="Subscribe" /><input type="submit" name="submit" value="Un-Subscribe" /> </form> <font size="1"><strong>Your email address is 100% confidential and will<br>remain that way.</strong></font></div> <?php } ?> Ok, in the end when someone submit's this, they can continue to resubmit it forever. I want a simple method to do this, because I just wanted to do it above the form, very easily. However, I don't want them to be able to re-submit the form over and over and over again and hit the system (in an attack or something). is there a way to easily prevent form re-submittal, or hitting the refresh button over and over again, and still have roughly this same setup. Quote Link to comment https://forums.phpfreaks.com/topic/47391-solved-re-submitting-forms/ Share on other sites More sharing options...
AndyB Posted April 17, 2007 Share Posted April 17, 2007 Sessions Quote Link to comment https://forums.phpfreaks.com/topic/47391-solved-re-submitting-forms/#findComment-231205 Share on other sites More sharing options...
Ninjakreborn Posted April 17, 2007 Author Share Posted April 17, 2007 hehe, we end up always overlooking the most basic things, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/47391-solved-re-submitting-forms/#findComment-231210 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.