聰明的查詢工作正常,我可以回顯電子郵件地址和與用戶名關聯的密碼,但是當它指出電子郵件正在發出時,我仍然不會在我的郵箱中收到它。任何想法出了什麼問題?爲什麼我的php忘記密碼不發送電子郵件
這裏是我的全碼:
<?php session_start();
mysql_connect("localhost","root","");//database connection
mysql_select_db("database");
if (isset($_POST['username'])){
$username = $_POST['username'];
$query="select * from dbusers where username='$username'";
$result = mysql_query($query);
$count=mysql_num_rows($result);
// If the count is equal to one, we will send message other wise display an error message.
if($count==1)
{
$rows=mysql_fetch_array($result);
$pass = $rows['password'];//FETCHING PASS
echo "your pass is ::".($pass)."";
$to = $rows['email'];
echo "your email is ::".$to;
//Details for sending E-mail
$from = "Your Password details";
$url = "http://localhost.com";
$body = "Reset Password
-----------------------------------------------
Url : $url;
email Details is : $to;
Here is your password : $pass;
Sincerely,
Coding Cyber";
$from = "[email protected]";
$subject = "Here's your new password";
$headers1 = "From: $from\n";
$sentmail = mail ($to, $subject, $body, $headers1);
} else {
if ($_POST ['username'] != "") {
echo "No such username found!</span>";
}
}
//If the message is sent successfully, display sucess message otherwise display an error message.
if($sentmail==1)
{
echo "<span style='color: #ff0000;'> Your Password Has Been Sent To Your Email Address.</span>";
}
else
{
if($_POST['username']!="")
echo "<span style='color: #ff0000;'> Cannot send password to your e-mail address.Problem with sending mail...</span>";
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home: Webpage</title>
</head>
<body>
<form action="" method="post">
<label> Enter your User ID : </label>
<input id="username" type="text" name="username" />
<input id="button" type="submit" name="button" value="Submit" />
</form>
</body>
</html>
它不起作用的事實是PHP告訴你永遠不應該存儲純文本密碼的方式。 – PeeHaa
你有郵件服務器嗎? – Christian
@christian我只有xampp以phpmyadmin和apache運行。 – user3015758