searls03 Posted April 26, 2011 Share Posted April 26, 2011 is there a way to make a mail function submit only once? so that if you go forward a page, then back, it won't resubmit? Quote Link to comment https://forums.phpfreaks.com/topic/234758-run-mail-function-once/ Share on other sites More sharing options...
Muddy_Funster Posted April 26, 2011 Share Posted April 26, 2011 there are a couple of ways, header redirect is the most popular (I think) Quote Link to comment https://forums.phpfreaks.com/topic/234758-run-mail-function-once/#findComment-1206437 Share on other sites More sharing options...
searls03 Posted April 26, 2011 Author Share Posted April 26, 2011 but how do I make it so that the page doesn't even load, cause the redirect is on the page which loads first isn't it? and that would make it so the first time it would also redirect wouldnt it? Quote Link to comment https://forums.phpfreaks.com/topic/234758-run-mail-function-once/#findComment-1206438 Share on other sites More sharing options...
Muddy_Funster Posted April 26, 2011 Share Posted April 26, 2011 Not if the mail proccessing page is set to check the existance of a variable that is unset during the proccess. you would then completed page seporate again, using a header at the end of the mail process, taking you to another page, so that if you press the back button from this page the variable will come through as unset and you can redirect (using another header) to wherever you want them to go. If your comfortable enough with using IF you could have it all on the one page. Quote Link to comment https://forums.phpfreaks.com/topic/234758-run-mail-function-once/#findComment-1206449 Share on other sites More sharing options...
searls03 Posted April 26, 2011 Author Share Posted April 26, 2011 what would this code look like? Quote Link to comment https://forums.phpfreaks.com/topic/234758-run-mail-function-once/#findComment-1206453 Share on other sites More sharing options...
Muddy_Funster Posted April 26, 2011 Share Posted April 26, 2011 which part? and how are you implememting it - one page or multiple? Quote Link to comment https://forums.phpfreaks.com/topic/234758-run-mail-function-once/#findComment-1206454 Share on other sites More sharing options...
searls03 Posted April 26, 2011 Author Share Posted April 26, 2011 Quote Link to comment https://forums.phpfreaks.com/topic/234758-run-mail-function-once/#findComment-1206462 Share on other sites More sharing options...
searls03 Posted April 26, 2011 Author Share Posted April 26, 2011 second half: <?php $sql = ("SELECT * FROM Events WHERE eventid='$eventid' && userid='$userid'"); $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $event = $row['event']; $startdate = $row['startdate']; $enddate = $row['enddate']; $description = $row['description']; $location = $row['location']; $subevent1 = $row['subevent1']; $subevent2 = $row['subevent2']; $subevent3 = $row['subevent3']; $subevent4 = $row['subevent4']; $subevent5 = $row['subevent5']; $subevent6 = $row['subevent6']; $subevent7 = $row['subevent7']; $subevent8 = $row['subevent8']; } if (!empty($title1)) { $message .= "<br/>$title1"; } if (!empty($title2)) { $message .= "<hr><br/>$title2" ; } if (!empty($title3)) { $message .= "<hr><br/>$title3"; } if (!empty($title4)) { $message .= "<hr><br/>$title4"; } if (!empty($title5)) { $message .= "<hr><br/>$title5"; } if (!empty($title6)) { $message .= "<hr> <br/>$title6"; } if (!empty($title7)) { $message .= "<hr><br/>$title7"; } if (!empty($title8)) { $message .= "<hr><br/>$title8"; } echo "</div>"; ?> <?php $message .="</th> </tr> <tr> <th>Price:</th> <th>$ $total </th> </tr> <tr> <th>Registrant:</th> <th> $name</th> </tr> </table> </div></th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> </tr> <tr> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> </tr> <tr> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> </tr> <tr> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> </tr> <tr> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> </tr> <tr> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> <th scope='col'> </th> </tr> </table> </body> </html>"; // end of message $headers = "From: $from\r\n"; $headers .= "Content-Type: text/html\r\n"; $to = "$to"; // Finally send the activation email to the member mail($to, $subject, $message, $headers); echo mysql_error(); // close if post exit(); // Exit so the form and page does not display, just this success message }// Close else after database duplicate field value checks // Close else after missing vars check //Close if $_POST ?> </p> <p> </p> <br /><br /> </div> <script type="text/javascript"> var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"../SpryAssets/SpryMenuBarDownHover.gif", imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"}); </script> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/234758-run-mail-function-once/#findComment-1206465 Share on other sites More sharing options...
Muddy_Funster Posted April 26, 2011 Share Posted April 26, 2011 this : if (isset($_POST['eventid'])){ is an example of checking to see if a variable is set. isset and unset are native php functions for checking and dropping variables. Quote Link to comment https://forums.phpfreaks.com/topic/234758-run-mail-function-once/#findComment-1206474 Share on other sites More sharing options...
searls03 Posted April 26, 2011 Author Share Posted April 26, 2011 ok, sorry, where would I put something like that? Quote Link to comment https://forums.phpfreaks.com/topic/234758-run-mail-function-once/#findComment-1206479 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.