我有一個包含用戶的電子郵件,並自動生成用戶名數據庫的電子郵件,我必須在用戶輸入自己的電子郵件找回自己的用戶名形式,這裏是我的代碼試圖發送用戶名使用PHP
<html>
<body>
<form method="post" action="retrievedetails.php">
<p><label for="email">Email:</label>
<input name="email" type="text"/>
</p>
<input type="submit" name="submit" value="submit"/>
</form>
<?php
session_start();
$connect=mysql_connect("localhost","dfarrelly","1234") or die("Could not connect to database");
mysql_select_db("game", $connect) or die("Couldn't find db");
if(isset($_POST['submit'])) {
$email=$_POST['email'];
$email_check=mysql_query("SELECT user_name FROM details WHERE user_email='$email'");
$name=mysql_num_rows($email_check);
$subject="Login Info";
$message="Your username is .$name";
$from="From: [email protected]";
mail($email, $subject, $message, $from);
echo "your username has been emailed to you";
}
?>
</body>
</html>
我沒有收到任何錯誤,我只是沒有收到電子郵件,任何人都可以幫助我?
也許涉及到您的垃圾郵件? – Danielius
在本地服務器上工作? – Dave
此代碼開放給SQL注入攻擊:https://stackoverflow.com/documentation/php/275/using-a-database/2685/sql-injection-and-prevention –