Jump to content

forgotpassword script help


chriscloyd

Recommended Posts

Hey this is my changepassword script on the site

http://www.chaoslegionclan.net/cegl/index.php?page=forgotpassword

no matter what i do it does not work it returns as an error saying there is no account

and im 100% sure that the username and email address im entering are correct lol

 

<?php
session_start();
include("config.php");
$email = $_POST['email'];
$username = $_POST['username'];
//check email
$check_email = mysql_query("SELECT * FROM users WHERE username = '$username'");
if ($check_email_address) {
$check_email_nums = mysql_num_rows($check_email_address);
if ($check_email_nums > 0) {
	$check_email = mysql_fetch_array($check_email_address);
	if ($check_email['user_email'] == $email) {
		$characters = 10;
		$possible = '23456789bcdfghjkmnpqrstvwxyz';
		$code = '';
		$i = 0;
		while ($i < $characters) { 
			$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
			$i++;
		}
		$newpass = $code;
		$password = md5($code);
		mysql_query("UPDATE users SET user_password = '$newpass' WHERE username = '$username'") or die(mysql_error());
		$newpass = generatepassword_forgotpassword(;
		$encryptedpw = md5($newpass);
		$to = $email;
		$subject = "[email protected] - New Password";
		$message = "You requested a new password
Your new password is: $newpass
If you need any further help just ask.

VAL-Support Staff";
		$from = "[email protected]";
		$headers1 = "MIME-Version: 1.0\r\n";
		$headers1 .= "Content-type: text/html; charset=iso-8859-1\r\n";
		$headers1 .= "To: ".$to."\r\n";
		$headers1 .= "From: ".$from."\r\n";
		$headers1 .= "Reply-To: ".$from."\r\n";
		mail($to, $subject, $message, $headers);
		header("Location: ../index.php?page=newpass");
	}
} else {
	$reasons = '-There is no account with that username.';
	header("Location: ../index.php?page=forgotpassword&error=$reasons");
}
} else {
$reasons = '-There is no account with that username.';
header("Location: ../index.php?page=forgotpassword&error=$reasons");
}
?>

Link to comment
https://forums.phpfreaks.com/topic/46831-forgotpassword-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.