【发布时间】:2016-01-19 14:16:55
【问题描述】:
所以,我一直在尝试使用 PHP 和 MySQL 创建一个注册/登录流程。我创建了一个注册表单和一个处理页面。然后我试了一下,将电子邮件设置为a@a.com,密码设置为MyPassword。
然后我检查了数据库并感到惊讶。电子邮件输入正确,可以,但密码不正确!这是我之前测试过的密码之一,而且是一个非常私人的密码。
每次我再次尝试时,都会发生同样的事情。每当我注册时,密码总是更改为我的个人密码。
问题是,在我的代码中,我在任何地方都没有那个个人密码。我只用它来测试我的注册流程一次,现在它卡在了我的数据库中!
在这里,我使用测试凭据进行了注册。密码是asd,显然是3个字母。
但是当我检查数据库时,我看到以下内容。尽管我编辑了密码,所以你看不到它,但很明显它的长度超过了 3 个字母。
这是某种我还不知道的 MySQL 重写吗?
这是注册页面的完整代码(可能有点长,请耐心等待):
<?php
session_start();
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$email = $_POST['signUpemail'];
$password = $_POST['signUppassword'];
include("mysql_base.php");
echo "Preparing MYSQL Statement...<br>";
echo "<script>";
echo "firstPart()";
echo "function firstPart() {";
echo "document.write('Starting to process MYSQL Statement...')";
echo "window.setTimeout(secondPart(),2000)";
echo "}";
echo "function secondPart() {";
echo "document.write('Starting to stop processing MSYQL Statement...')";
echo "}";
echo "</script>";
echo "Started to proccess...<br>";
$sql = "INSERT INTO pages_accounts (email, pass, firstname, lastname, confirm) VALUES ('".$email."','".$password."','".$firstName."','".$lastName."','0')";
if ($conn->query($sql) === true){
echo "<b>SIGNUP SUCCESS</b><br>";
echo "SUCH HAPPINESS. WOW. MMM.<br><br>";
echo "--Check your mail for a confirmation email. Check SPAM too!--";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: FoxInFlame Pages<pages@foxinflame.tk>' . "\r\n";
$message = "
<html>
<body>
<center>
<div style='background-color:orange'><h1>Confirm your Account</h1><br><h3>At FoxInFlame Pages</h3></div>
You seem to have registered for an account at FoxInFlame Pages. Now please click on the following link to complete your registration, and start creating amazing websites!<br><a href='http://www.foxinflame.tk/pages/confirm.php?id=".$conn->insert_id."'>Click Here</a>
</center>
</body>
</html>
";
mail($email, "[CONFIRM] Account on FoxInFlame Pages", $message);
} else {
echo "MUCH SADNESS. SUCH DEPRESSION. FAIL ERROR. NO RETURN.";
echo "Error: ".$sql."<br>".$conn->error;
};
?>
【问题讨论】:
-
密码是否已保存到浏览器表单字段历史记录中?可以发一些代码吗?
-
查看登录/注册页面不如查看代码重要。我的猜测是存在 SQL 注入漏洞。
-
请勿访问链接 - 这只是垃圾邮件
-
您的代码容易受到SQL Injection 的攻击。你也应该是Hashing your passwords。
-
是的,删除表的能力。当您故意导致错误时,它还会公开您的一些表模式。例如:setting the first name to
'shows me the table structure, and your password
标签: php mysql login replace passwords