Forums

PHP

This topic is locked

Sent Password Redirect

Posted 22 Nov 2006 18:33:13
1
has voted
22 Nov 2006 18:33:13 Steve Hines posted:
Hey All, thanks for your help on my last problems, Big Help!

One last thing, I have a forgot password script that works fine. The problem is once the email is sent, it comes back to the send password page. The messages work fine saying that the val code is not right, or the email address was not in the database, But i want it to redirect to a different page if the email was sent properly so that i dont confuse the user. here is the codeL

<?php
session_start();
$colname_rstUser = "";
$message = "";
$from = "here is your ";
$headers = "From: $from";
if (isset($_POST['e-mail'])) {
if ($_SESSION['valcode']==$_POST['valcode']) {
$colname_rstUser = (get_magic_quotes_gpc()) ? $_POST['e-mail'] : addslashes($_POST['e-mail']);
mysql_select_db($database_foxthermal, $foxthermal);
$query_rstUser = sprintf("SELECT user_email, user_password FROM users WHERE user_email
= '%s'", $colname_rstUser);

$rstUser = mysql_query($query_rstUser, $foxthermal) or die(mysql_error());
$row_rstUser = mysql_fetch_assoc($rstUser);
$totalRows_rstUser = mysql_num_rows($rstUser);
if ($totalRows_rstUser > 0) {
mail($row_rstUser['user_email'],"Your password","Your password is:
".$row_rstUser['user_password'],$headers);
$message = "Your password has been e-mailed to you";
} else {
$message = "Sorry, the e-mail address you supplied is not in our database";
}
} else {
$message = "Sorry, but the validation code that you entered was incorrect";
}
}
$_SESSION['valcode'] = sprintf("%04d",mt_rand(1,9999));
?>

Replies

Replied 23 Nov 2006 12:34:09
23 Nov 2006 12:34:09 ASif Iqbal replied:
well this could be also done the same way i replied u for ur last post.

if ($totalRows_rstUser > 0) {

If(@mail($row_rstUser['user_email'],"Your password","Your password is:
".$row_rstUser['user_password'],$headers)<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
{
$message = "Your password has been e-mailed to you";
redirect to your thank you page
}
esle
{
error page
}
}

Reply to this topic