所以,我一直在尝试使用PHP和MySQL创建一个注册/登录过程。我创建了一个注册表单和一个处理页面。然后我将其删除,将电子邮件设置为a@a.com
,将密码设置为MyPassword
。
每次我再次尝试时,都会发生同样的事情。每当我注册时,密码总是更改为我的个人密码。
问题在于,在我的代码中,我无法在任何地方拥有该个人密码。我只用它来测试我的注册流程一次,现在它已经卡在我的数据库中了!
在这里,我使用测试凭证进行了注册。密码为asd
,显然长3个字母。
但是当我检查数据库时,我看到以下内容。尽管我编辑了密码以便您无法看到密码,但它的长度超过3个字母仍然很明显。
这是某种MySQL覆盖的东西,我还不知道吗?
以下是SignUp页面的完整代码(可能有点长,请耐心等待):
<?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;
};
?>
答案 0 :(得分:1)
您的问题将出现在include("mysql_base.php");
中。该文件将为其自己的内部使用设置$password
,这将覆盖您从$password
获得的$_POST
变量;
解决这个问题的2个选项:
1 - 首先打开数据库连接。
<?php
session_start();
include("mysql_base.php");
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$email = $_POST['signUpemail'];
$password = $_POST['signUppassword'];
2 - 使用不同的变量名称:
<?php
session_start();
include("mysql_base.php");
$signup_firstName = $_POST['firstName'];
$signup_lastName = $_POST['lastName'];
$signup_email = $_POST['signUpemail'];
$signup_password = $_POST['signUppassword'];
除此之外,注册页面上的密码字段没有name="signUppassword"
,并且您没有SQL注入保护。
答案 1 :(得分:0)
在您的页面上,我看到:
<input style="color:white" type="password" name="password" required="" autocomplete="off">
因此,您的输入名称为密码
但是在您的代码中,您正试图获得 signUppassword :
$password = $_POST['signUppassword'];
你在某处有变化吗? JavaScript的?