我现在的注册脚本已经很远了。这对我来说是一个惊人的学习曲线。到目前为止,我刚刚完成了一些关于我的用户识别和注册电子邮件发送的错误。不过,我在恢复密码方面遇到了一些问题。目前我只是想让一封电子邮件得到认可,这是我的 HTML 和 PHP:
HTML
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<?php include "header.php" ?>
<div id="wrapper">
<form method="post" action="">
<h2>Recover Password</h2>
<div id="underline"></div>
<ul>
<li>
<label for="usn">Email : </label>
<input type="text" maxlength="30" required autofocus name="reset" />
</li>
<li class="buttons">
<input type="submit" name="reset" value="Reset Pass" class="xbutton" />
</li>
</ul>
</form>
</div>
</body>
</html>
<?php include "prec.php" ?>
PHP
<?php
if($_POST)
{
if(empty($_POST['reset']))
{
echo 'Please enter all fields';
}
else
{
$email = $_POST['reset'];
$password = $_POST['password'];
$db_name =
$db_user =
$db_pass =
$conn = new PDO('mysql:host=localhost;dbname=tweezy_php', 'tweezy_php', 'XXXXXX',
array( PDO::ATTR_PERSISTENT => true ));
$stmt = $conn->prepare("SELECT email FROM users WHERE email = ? ");
$stmt->execute(array($email));
if($stmt->rowCount() === 1 )
{
echo "That email exists";
}
else
{
echo "Sorry, that email doesn't exsist.";
}
}
}
?>
出于某种原因,无论我输入什么,提供的电子邮件都无法识别。浏览我的代码,我不太明白为什么。我尝试了几种变体,但它似乎给了我相同的结果。我认为这与我的 SQL 查询有关,但我似乎无法完全理解它。
任何见解都会很棒!