rtadams89 Posted December 14, 2008 Share Posted December 14, 2008 I have the following code: <?php $gzip_off = 1; require($_SERVER['DOCUMENT_ROOT'].'/includes/config.php'); require($_SERVER['DOCUMENT_ROOT'].'/includes/functions.php'); if (($auth_lvl >= 2) && (isset($_GET['id']))) { //Email members on addition of new event. $id = $_GET['id']; mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error()); mysql_select_db(DB_NAME) or die(mysql_error()); $sql = "SELECT d, m, y, title, text FROM calendar WHERE id=" . $id; $result = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($result); $d = $row["d"]; $m = $row["m"]; $y = $row["y"]; $title = $row["title"]; $text = $row["text"]; ob_start(); ?> <html> <head> <title>DO NOT CLOSE</title> </head> <body> <center><b>DO NOT CLOSE THIS WINDOW!</b> <br>E-Mails are being sent to members.</center> <? //Output buffering fix echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; ob_flush(); flush(); $recipients = calendar_mail(); $subject = 'New Event'; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: *** <no-reply@***.com>' . "\r\n"; $message = ' <html> <head> <title>New *** Event</title> </head> <body> <p>A new event has been posted on the <a href="http://www.***.com/schedule.php">***.com calendar</a>.</p> <br>Event Title: '.$title.' <br>Event Date: '.$m . "/" . $d . "/" . $y.' <br>Added by: '.$name.' <br>Event Details: '.$text.' <br><br>If you want to stop receiving notices when new events are added, you can change your notification preferences here: <a href="http://www.***.com/user_cp.php">http://www.asurfc.com/user_cp.php</a>. </body> </html> '; mail($recipients, $subject, $message, $headers); echo "<br><center><font color='RED'><b>You may now close this window.</b></font></center></body></html>"; } else { echo "ERROR"; } ?> As you can see, it uses output buffering to alert users that a PHP script is still running (sending emails in this case) and then notifies the user when the script finishes. Is there anyway to cause the window to close automatically when the script finishes? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 14, 2008 Share Posted December 14, 2008 have you tried javascript? window.close Quote Link to comment Share on other sites More sharing options...
rtadams89 Posted December 14, 2008 Author Share Posted December 14, 2008 Right, but how would I get that to run? If I trigger it with the body onLoad event handler, it will run prematurely, and close the page before the email script runs. Quote Link to comment 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.