Jump to content

[SOLVED] Close Windows after PHP Script Finishes


rtadams89

Recommended Posts

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.