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 = "VAL@VALeague.net - 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 = "VAL@VALeague.net";
		$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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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