This below code using for receive the email for password, but email not sent due to some error. Kindly review the code and corrected, update the new code for send email. We are using forgot password in html and validate and email using php.
<?php
if(isset($_POST['submit'])) {
mysql_connect('localhost','connect','connect') or die(mysql_error());
mysql_select_db('connect') or die(mysql_error());
$Email_Address = $_POST['Email_Address'];
$q = mysql_query("SELECT * from erp_ng_form_reg WHERE Email_Address='$Email_Address' ") or die(mysql_error());
while($row = mysql_fetch_assoc($q)) {
$result[] = $row;
}
//$p = mysql_affected_rows();
//$res = mysql_fetch_array($q);
$to = $result['Email_Address'];
$message = $result['Password'];
$subject="Remind password";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
$m=mail($to, $subject, $message, $headers);
if($m) {
echo'Check your inbox in mail';
echo $message;
} else {
echo "<script language='javascript' type='text/javascript'>
var abc = document.getElementById('Email_Address').value;
alert(abc);</script>";
echo 'mail is not send';
}
}
?>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script>
<style type="text/css">
input {
border:1px solid olive;
border-radius:5px;
}
h1 {
color:darkgreen;
font-size:22px;
text-align:center;
}
</style>
</head>
<body>
<h1>Forgot Password<h1>
<form action='#' method='post'>
<table cellspacing='5' align='center'>
<tr>
<td>Email Address:</td><td><input type='text' id='Email_Address' name='Email_Address'/></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='submit' value='Submit'/></td>
</tr>
</table>
</form>
</body>
</html>
print_r($result)debug this ist, u will get the solution.print_r()is a function just for checking your$result, check what are you getting in$result...$to = $result['Email_Address'];useprint_r($result);and share the result.