<?
session_start();
include 'dbconnect.php';
$submit = $_POST['submit'];
if ($submit == 'Reset'){
		$email = $_POST['email'];
	$captcha = $_POST['captcha'];
	if ($captcha != $_SESSION['captcha'] ){
	echo 'Your captcha is off!';
	//header("Location: http://davidrtello.com	");
	}
	
$pass =makepass();
$encpass = md5(md5(md5($pass)));

$ins = $dbh->prepare("update users set credentials = ? where email = ? ");
$ins->execute(array($encpass,$email));

$content = 'your new  password is '.$pass."\n";
mail($email,'New password at mm214',$content);
echo 'Password changed! Check '.$email.'<br/>';

}






?>
Enter your email to reset your password!
<form action = "resetpw.php" method = "post">
Email:<input type = "text" name="email" /><br/>
<img src = "captcha.php"/><br/>
  Enter the code you see above: <input type = "text" name = "captcha"/> <br/> 
<input type = "submit" name = "submit" value = "Reset"/>
</form>