I am new to website design and I have recently made a website and i would like to add a reset password function, it doesn't work.
The SQL connection is inside of the init.php file
<?php
include('core/init.php');
include('includes/overall/header.php');
echo "
<h1>Reset Password</h1>
<div class='Reset' align='center'>
<form action='forgot_pass.php' method'POST'>
Enter your username<br><input type='text' name='username'><p>
<br>
Enter your email<br><input type='email' name='email'><p>
<input type='submit' value='Submit' name='submit'>
</form>
</div>
";
if (isset($_POST['submit']))
{
$username = $_POST['username'];
$email = $_POST['email'];
$query = mysql_query("SELECT * FROM `users` WHERE `username`='$username'");
$numrow = mysql_num_rows($query);
if ($numrow!=0)
{
while($row = mysql_fetch_assoc($query))
{
$db_email = $row['email'];
}
if ($email == $db_email)
{
$code = rand(10000,1000000);
$to = $db_email;
$subject = "Password Reset";
$body = "
Automated email. Click the link
http://ift.tt/1U1Buug
";
mysql_query("UPDATE users SET passreset='$code' WHERE username='$username'");
mail($to,$subject,$body);
echo "Check Email";
}
else
{
echo "Email not correct";
}
} else {
echo "That user does not exist";
}
}
?>
I will be so happy if somebody could help me thanks
Aucun commentaire :
Enregistrer un commentaire