I try to use the mail() function to enable the user to send their acknowledgement of losing password to my email account. well i set the smtp in php.ini, still it is not working. The code is attached as below :-
Any help will be greatly appreciated. TQ
Code: Select all
<html>
<head>
<h2>
User Login
</h2>
<form method=post action="emailForgetPw.php">
</head>
<body>
<b>
<br>
Username
<br>
</b>
<input type=text size=15 name="username">
<br>
<b>
Email
</b>
<br>
<input type=text size=15 name="email">
<br>
<input type=submit name=submit value="Login">
<input type=reset name=reset value="Clear">
<br>
</form>
</body>
</html>Code: Select all
<?
$username = $_POSTї'username'];
$email = $_POSTї'email'];
if ($submit = "Login")
{
mysql_connect("localhost", "admin", "123") or
die ("Could not connect to database");
mysql_select_db("test") or
dir ("Could not select database");
$qry = mysql_query("select first_name,last_name,email from users where username='$username'
and email='$email'");
$fetch = mysql_fetch_row($qry);
if ($fetch > 0){
$first_name = $fetchї0];
$last_name = $fetchї1];
$email = $fetchї2];
}
?>
<?php
$mailto = "Anusuriya <anusuriya_asd@yahoo.com>";
$subject = "Forget Password";
$message = "Hello!\n I have forgotten my password.Please reset my password.\n\n";
$message = $message."My name is $first_name.$last_name";
$extra = "From: $email\r\nReply-To: $email\r\n";
if(@mail($mailto, $subject, $message,$mailfrom)){
echo "You new password has been forwarded to your specified email account. ";
}
else{
echo "Error! New password failed to be sent. Please contact portal master.\n";
}
?>