elmas156 Posted October 9, 2008 Share Posted October 9, 2008 Hello everyone, I'm baffled by this problem that I'm having. Basically, I have a page that updated a database and sends an automatic email using the mail() function. Everything works perfectly until I add the following code between the <head></head> tags, in which it seems the page is processed twice, causing it to send the same email twice. I don't know what's going on... any ideas? Here's the code that I'm adding: <style type="text/css"> <!-- body { margin-top: 0px; margin-left: 0px; background-image: url(); background-color: #CCCCCC; } body,td,th { color: #000000; font-family: Times New Roman, Times, serif; font-size: 16px; } a:link { text-decoration: none; } a:visited { color: #0000CC; text-decoration: none; } a:hover { color: #FF0000; text-decoration: underline; } a:active { color: #000000; text-decoration: none; } --> </style> and this is the entire page code... it's pretty short: <?php $apptid=$_GET['apptid']; $result6 = mysql_query("SELECT * FROM appts WHERE apptid = '$apptid'"); if (!$result6) { echo 'Could not run query: ' . mysql_error(); exit(); } $row2 = mysql_fetch_array($result6); $year = $row2[ "year" ]; $color = $row2[ "color" ]; $make = $row2[ "make" ]; $model = $row2[ "model" ]; $apptdate = $row2[ "apptdate" ]; $result7 = mysql_query("SELECT * FROM users WHERE email = '$email'"); if (!$result7) { echo 'Could not run query: ' . mysql_error(); exit(); } $row3 = mysql_fetch_array($result7); $fname = $row3[ "fname" ]; $lname = $row3[ "lname" ]; //email customer $to = "$email"; $subject = "Alleyway Oil & Lube Appointment Cancelled."; $message = "<html> <body> <center><a href=\"http://www.alleywayoil.com\"><img src=\"http://www.alleywayoil.com/logo.gif\" border=\"0\" alt=\"Alleyway Oil & Lube\"></a></center> Hello $fname,<p> Your service appointment for your $year $color $make $model on $apptdate has been cancelled. If this appointment was cancelled by accident you may reschedule online at <a href=\"http://www.alleywayoil.com\">www.alleywayoil.com</a> Thank you for choosing Alleyway Oil & Lube for your basic vehicle service.<br> <br> Sincerely,<br> Alleyway Oil & Lube Management Team<br> <br> </body> </html>"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: Alleyway Oil & Lube <[email protected]>' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); //email me $tome = "[email protected]"; $mysubject = "Apptointment Cancelled"; $mymessage = "<html> <body> Appointment ID:<br> $apptid<br> <br> Service Date:<br> $apptdate<br> <br> </body> </html>"; // To send HTML mail, the Content-type header must be set $myheaders = 'MIME-Version: 1.0' . "\r\n"; $myheaders .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $myheaders .= 'From: Cancellations <[email protected]>' . "\r\n"; // Mail it mail($tome, $mysubject, $mymessage, $myheaders); mysql_query("DELETE FROM appts WHERE apptid = '$apptid'"); echo "<meta http-equiv=\"refresh\" CONTENT=\"0; URL=members.php\">"; mysql_close($db_connect); // Closes the connection. ?> Link to comment https://forums.phpfreaks.com/topic/127765-mail-page-being-processed-twice/ Share on other sites More sharing options...
Brandon Jaeger Posted October 9, 2008 Share Posted October 9, 2008 Where are the <HEAD> tags? I don't see them in your script anywhere. That could be a problem. Link to comment https://forums.phpfreaks.com/topic/127765-mail-page-being-processed-twice/#findComment-661357 Share on other sites More sharing options...
elmas156 Posted October 9, 2008 Author Share Posted October 9, 2008 I'm sorry, I said that the second part of the code was the entire page code but I meant that it's the part of the code that is being processed twice... sorry about that, my mistake. There are head and html and body tags... Here is the ENTIRE code: <?php session_start(); // Starts the session. ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Alleyway Oil & Lube - Cancel Your Appointment</title> <script language="javascript"> function cancelled() { alert("Your appointment has been cancelled"); } </script> <!--menu script--> <script src="menuscript.js" language="javascript" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="menustyle.css" media="screen, print" /> <!--end script--> <!--THIS IS WHERE I'M TRYING TO ADD THE ABOVE CODE--> </head> <body onUnload="cancelled()"> <div align="left"> <table width="999" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" valign="top"> <!-- Page Starts Here --> <?php include("head.inc.php"); include("conf.inc.php"); $email=$_SESSION['email']; if ($_SESSION['logged'] != 1 || $email == "") { // There was no session found! $_SESSION['email'] = $email; echo "<meta http-equiv=\"refresh\" CONTENT=\"0; URL=index.php\">"; // Goes to login page. exit(); // Stops the rest of the script. } ?> <table width="990" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="155" align="left" valign="top"> <!-- Left Column Start --> <?php include("left.inc.php"); ?> <!-- Left Column End --> </td> <td width="680" align="center" valign="top"> <!-- Center Column Start --> <?php $apptid=$_GET['apptid']; $result6 = mysql_query("SELECT * FROM appts WHERE apptid = '$apptid'"); if (!$result6) { echo 'Could not run query: ' . mysql_error(); exit(); } $row2 = mysql_fetch_array($result6); $year = $row2[ "year" ]; $color = $row2[ "color" ]; $make = $row2[ "make" ]; $model = $row2[ "model" ]; $apptdate = $row2[ "apptdate" ]; $result7 = mysql_query("SELECT * FROM users WHERE email = '$email'"); if (!$result7) { echo 'Could not run query: ' . mysql_error(); exit(); } $row3 = mysql_fetch_array($result7); $fname = $row3[ "fname" ]; $lname = $row3[ "lname" ]; //email customer $to = "$email"; $subject = "Alleyway Oil & Lube Appointment Cancelled."; $message = "<html> <body> <center><a href=\"http://www.alleywayoil.com\"><img src=\"http://www.alleywayoil.com/logo.gif\" border=\"0\" alt=\"Alleyway Oil & Lube\"></a></center> Hello $fname,<p> Your service appointment for your $year $color $make $model on $apptdate has been cancelled. If this appointment was cancelled by accident you may reschedule online at <a href=\"http://www.alleywayoil.com\">www.alleywayoil.com</a> Thank you for choosing Alleyway Oil & Lube for your basic vehicle service.<br> <br> Sincerely,<br> Alleyway Oil & Lube Management Team<br> <br> </body> </html>"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'From: Alleyway Oil & Lube <[email protected]>' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); //email me $tome = "[email protected]"; $mysubject = "Apptointment Cancelled"; $mymessage = "<html> <body> Appointment ID:<br> $apptid<br> <br> Service Date:<br> $apptdate<br> <br> </body> </html>"; // To send HTML mail, the Content-type header must be set $myheaders = 'MIME-Version: 1.0' . "\r\n"; $myheaders .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $myheaders .= 'From: Cancellations <[email protected]>' . "\r\n"; // Mail it mail($tome, $mysubject, $mymessage, $myheaders); mysql_query("DELETE FROM appts WHERE apptid = '$apptid'"); echo "<meta http-equiv=\"refresh\" CONTENT=\"0; URL=members.php\">"; mysql_close($db_connect); // Closes the connection. ?> <!-- Center Colum End --> </td> <td width="155" align="right" valign="top"> <!-- Right Column Start --> <?php include("right.inc.php"); ?>; <!-- Right Column End --> </td> </tr> </table> <!-- Page Ends Here --> </td> </tr> </table> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/127765-mail-page-being-processed-twice/#findComment-661360 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.