Hello,
I am having problems getting a script to work right.
<?
session_start();
//start up the ob...
ob_implicit_flush();
$userid = $_GET['userid'];
$wherefield=$_GET['wherefield'];
$searchvalue=$_GET['searchvalue'];
$sortby=$_GET['sortby'];
$asc=$_GET['asc'];
/* You may need to send a "buffer-buster" to force output... uncomment if needed.
for ($i=0;$i<300;$i++) {
$str .= " ";
}
*/
$a = 0;
//now start your looping for output...
for ($i=0;$i<8;$i++) {
//we snooze for a nice effect here...
sleep(1);
//and output...
echo "<strong>";
if($a=="0"){
echo "Reseting Password....<br>";
$a=1;
}
elseif($a=="1"){
include 'db-login.php';
$newpass = "password";
$encrypt=md5($newpass);
mysql_query("UPDATE Users SET Password='$encrypt' WHERE UserID='$userid'")or die(mysql_error());
echo "Password Reset.<br>";
echo "Sending E-mail to user...<br>";
$a=2;
}
elseif($a=="2"){
$info = mysql_query("SELECT * FROM Users WHERE UserID='$userid'")or die(mysql_error());
$row = mysql_fetch_array($info);
$email = $row['Email'];
$subject = "Your Password";
$sitename1 = "Bibleway Community of Faith -- SCE";
$message ="
Your password has been reset. Your new password is: password
This e-mail is not spam. You have recieved this e-mail because you or an administrator has reset your password for Bibleway Community of Faith.
This is an automatic e-mail, please do not reply. This e-mail was created by Johnie Karr of Data Management Technologies www.datamt.org";
mail($email, $subject, $message, "From: $sitename1 <sce@bcof.org>\X-Mailer: PHP/" . phpversion());
echo "E-mail notification sent.<br>";
echo "Redirecting In 5 Seconds";
$a=3;
}
elseif($a=="3"){
echo "<font color=red>";
echo " .";
$a=4;
}
elseif($a=="4"){
echo " .";
$a=5;
}
elseif($a=="5"){
echo " .";
$a=6;
}
elseif($a=="6"){
echo " .";
$a=7;
}
elseif($a=="7"){
echo " .";
echo "</font></strong>";
}
}
echo "<http-equiv=refresh content=0;url=usersearchdisplay.php?wherefield=$wherefield&searchvalue=$searchvalue&asc=$asc&sortby=$sortby>";
ob_end_flush();
?>
I know I'm missing the word meta in the refresh tag, that's because I don't want it to refresh during the test.
The script should do the following:
Psuedo Code:
echo: Reseting Password [delay 1 second]
echo: password reset, sending e-mail notification [delay 1 second]
echo: e-mail notification sent, redirecting in 5 seconds [delay 1 second]
echo: . [delay 1 second]
echo: . [delay 1 second]
echo: . [delay 1 second]
echo: . [delay 1 second]
echo: . [delay 1 second]
End Psuedo Code
It works correctly if the browser is already on that page and the page is simply refreshed. If the page, however, is brought up with a link, then it doesn't work, It does all the sleep() functions first (so it waits 8 seconds) and then it quickly displays the text (and with the refresh automatically refreshes).
Does anyone have any ideas on how I can make this work correctly?
Thanks,
Johnie Karr