Jump to content

Recommended Posts

Hi guys, How do i prevent it from resubmitting? When ever, i go back and submit again. It will have multiple echo out different names.

 

Heres my php.

 

<?php
include("connect.php");
  if(isset($_GET['process']))
  {
$emailCheck = mysql_query("SELECT email, mobile FROM user_info WHERE email = '$_POST[email]' OR mobile = '$_POST[mobile]'") or die (mysql_error());
$number = mysql_num_rows($emailCheck);
if ($number > 0) {
echo "You already registered.";
}
else {
$query = "Insert INTO user_info (lastname, firstname, email, mobile, gender) values('$_POST[lastname]', '$_POST[firstname]','$_POST[email]','$_POST[mobile]', '$_POST[gender]')";
   $result = mysql_query($query) or die(mysql_error());
   if(!$result)
   {
 echo "Opps something went wrong. Please try again. ERROR: ".mysql_error();
   }
   else
   {
$name = $_POST['firstname'];
$query = "select * from user_info where firstname = '$name'";
$result = mysql_query($query);
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$email = $_POST[email];
$EmailSubject = "You've Just Registered On Health Board";
$mailheader = "From: ken@tagssg.com\n";
$mailheader .= "Reply-To: ken@tagssg.com\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY .= "Dear " . $line['lastname'] . " " . $line['firstname'] .  ",</h1>" . "<br /><br />Thank you for registering with us, I hope you have a good day.<br /><br />Regards,<br /><br />Health Board";
mail($email, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Encounter some error. Please contact ken@tagssg.com");
?>
<html>
<head>
<title>Submitted</title>
<meta http-equiv="refresh" content="5;url=index.html" />
<meta HTTP-EQUIV="Pragma" content="no-cache">
<meta HTTP-EQUIV="Expires" content="-1">
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
 <h1>Thank you,
   <?
echo $line['lastname'] ;
echo " ";
echo $line['firstname'] ;
?>
 </h1>
 Thank you for submitting.
 <p>In addition, a confirmation copy was sent to your e-mail address.</p>
 <p>You will be back in 5secs</p>
</div>
</body>
</html>
<?
}
}
   }
   }
mysql_close($db);
?>

 

Please excuse my coding... still new. Thanks

Link to comment
https://forums.phpfreaks.com/topic/269594-prevent-backrefresh-submitting/
Share on other sites

If you take a look at my rewrite of a login form, and pay attention to how I've structured it up (compared to the original), you should see how to do this quite nicely. The header call at the end, that sends the user to the confirmation page, prevents the F5 == resubmit problem.

My use of functions to perform most of the code also allows you to have much better control over which code paths gets executed, and how you can mix and match different functionality to get the desired results (without jumping through too many hoops).

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.