Jump to content

Reset Password Script Help


mat3000000

Recommended Posts

This works up until if (email == email2){

What is wrong? Is it a problem with the queries?

 

if(isset($_SESSION['rest']) || isset($_SESSION['chef'])){ header('Location:index.php');}

if (isset($_POST['submit'])) {
$errors = array();


// VALIDATION SCRIPT HERE


$newpass = generatepassword();

$link = mysql_connect("****","*****","******") or die ("Could not connect!");
mysql_select_db("****");
$query = "SELECT `username`, `type` FROM `users` WHERE `username`='$username'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
	{$type = $row['type'];}

$numrows = mysql_num_rows($result);
if ($numrows!=1){
$errors[] = 'Username not Found (Usernames are case sensitive)';}


if($email == '' || $username == ''){
$errors[] = 'Please Fill in all Fields';}


if (empty($errors)){
if ($type = 1){
	$res1 = mysql_query("SELECT `username`,`email` FROM `rests` WHERE `username`='$username'");
	while($row1 = mysql_fetch_array($res1))
	{$email2 = $row1['email'];}
}else{
	$res2 = mysql_query("SELECT `username`,`email` 		FROM `chefs` WHERE `username`='$username'");
	while($row2 = mysql_fetch_array($res2))
	{$email2 = $row2['email'];}


if ($email2 == $email)
{

echo $newpass;

mysql_query("UPDATE `users` SET  `password` = '$newpass' WHERE `username`='$username'");



//SEND EMAIL
$my_email = '[email protected]';
$email_from = 'Chef Match';
$email_subject = "Your New Password :: Chef Match";
$message = "Your new password is $newpass<br>You may change this via your control panel later.";

$referer = $_SERVER['HTTP_REFERER']; 
    $this_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"];  
    if ($referer != $this_url) { 
        echo "You do not have permission to use this script from another URL."; 
        exit; } 

$from = "From: $email2\r\n";
    mail($email2, $email_subject, $message, $from); 

    $thanks = 'An email has been sent to $email2 containing your new password. Please check your junk folder.'; 

}}
}else{$errors[] = 'Email did not match Username'; 
$thanks = 'Email could not be sent.';}
}


Link to comment
https://forums.phpfreaks.com/topic/228962-reset-password-script-help/
Share on other sites

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.