This question already has an answer here:
I have made a "forgot password" page so when the user submits their emailid
, then email matches from database and if email exists then password is sent to that email. The mail()
function is used to send the email. If I submit then message shows
Password sent to your email id. Please check your email now!
But message is not going in INBOX or SPAM. My hosting is LINUX hosting.
<form method="post" id="loginForm" name="loginForm" action="" onsubmit="return executeOnSubmit();">
<div class="col-lg-4" style="text-align:right;">
Email ID <span style="color:red">*</span>
</div>
<div class="col-lg-8">
<input type="email" class="form-control" value="<?php echo $email; ?>" name="email" placeholder="Enter email address" required />
</div>
<div style="clear:both;"><br /></div>
<div class="col-lg-4"></div>
<div class="col-lg-8 pull-right">
<input type="submit" class="btn btn-success" value="Submit" name="submit" />
</div>
</form>
<?php
$email = "";
if(isset($_POST["submit"]))
{
$email = $_POST["email"];
$res=mysql_query("select * from mainaccount where email='$email'") or die(mysql_error());
if($row = mysql_fetch_array($res))
{
extract($row);
$msg = "Hi User,
Email: ".$email."
Password: ".$password;
$smail=mail($email,"Scholarship Forgot Password!","Forgot Password Details: ",$password);
if(!$smail)
{
echo "<span style='color:red;'> — Mail Not Send!</span>";
}
else
{
echo " — Password sent to your email id. Please check your email now!";
}
}
else
{
echo "<span style='color:red;'>Email id does not match!</span>";
}
}
?>
</div>