gpt4 book ai didi

php - 我在提交帖子时不断收到 23750 作为密码

转载 作者:行者123 更新时间:2023-11-30 00:56:09 25 4
gpt4 key购买 nike

我完全被难住了。我正在为类(class)创建一个简单的成员(member)系统,无论我输入什么密码变体,我都会不断收到“23750”。首先我认为这是一个数据库问题,所以我手动输入了一个,这很好。然后,我将密码回显到下一页,但仍然得到 23750。我从头开始重新制作了表格,而数字 23750 根本不存在于我的任何代码中。有什么想法吗?无论如何,这是代码。

<?php 
// Check if user is logged in first
if ($_SESSION['logged_in']) { // user is logged in
header("Location: members.php");
}
$pageTitle = 'Register';
require('includes/header.php'); ?>
<div id="content">
<h3>Register</h3>
<?php

// Check if form has been submitted
if ($_SERVER['REQUEST_METHOD'] == 'POST') { // user submitted the form
// Validate info
// Grab variables
$email = $_POST['email'];
$email2 = $_POST['email2'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$gender = $_POST['gender'];
$age = $_POST['age'];
$address = $_POST['address'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
$pass_hint = $_POST['pass_hint'];

// Check if form was completely filled out
if ($email != "") { // email was filled out
if ($email2) { // verify email was filled out
if ($fname) { // first name was filled out
if ($lname) { // last name was filled out
if ($gender != 'select') { // gender was filled out
if ($age) { // age was filled out
if ($password) { // password was filled out
if ($password2) { // verification password was filled out
if (strlen($password) > 7) { // password is less than 8 characters}
if ($pass_hint) { // password hint was filled out
if ($password !== $pass_hint) { // password hint does not equal password
// All information was entered
// Check if email and password match each other
if ($email === $email2) { // emails match
if ($password === $password2) { // passwords match
// all form data is good, now check with database
require('includes/database.php'); // Connect to databae
// Check if email exists
$qry = $dbc->prepare("SELECT * FROM users WHERE email='$email'");
$qry->execute();

// Count rows
$count = $qry->rowCount();
if ($count != 1) { // email does not exist
// All information is good, insert to database
// Query database
$qry = $dbc->prepare("INSERT INTO users (email, fname, lname, gender, age, password, pass_hint) VALUES ('$email', '$fname', '$lname', '$gender', '$age', '$password', '$pass_hint');");
$qry->execute();

// Check if it was submitted successfully
$count = $qry->rowCount();
if ($count == 1) { // submitted successfully
echo $password;
echo 'You have been successfully registered, now forwarding you to the login page...';
?> <meta http-equiv="refresh" content="3;URL='login.php'" /> <?php
} else { // error submitting info
echo 'There was a system error, please contact the administrator';
registration_form();
}
} else { // email does exist
echo 'A user with that email already exists!';
registration_form();
}
} else { // passwords do not match
echo 'Your passwords must match!';
registration_form();
}
} else { // emails do not match
echo 'Your emails must match!';
registration_form();
}
} else { // password hint matches password given
echo 'Your password hint cannot equal your password!';
registration_form();
}
} else { // password hint was not filled out
echo 'Please enter a password hint';
registration_form();
}
} else { // password is not 8 characters or longer
echo 'Your password must be 8 characters of longer';
registration_form();
}
} else { // verification password was not filled out
echo 'Please enter your password twice!';
registration_form();
}
} else { // password aws not filled out
echo 'Please enter a password';
registration_form();
}
} else { // age was not filled out
echo 'Please enter your age';
registration_form();
}
} else { // gender was not filled out
echo 'Please select a gender';
registration_form();
}
} else { // last name was not filled out
echo 'Please enter your last name';
registration_form();
}
} else { // first name was not filled out
echo 'Please enter your first name';
registration_form();
}
} else {
echo 'Please enter your cerification email';
registration_form();
}
} else { // email was not filled out
echo "Please enter your email address!";
registration_form();
}


} else { // user did not submit form, show reg form
echo " <form action='register.php' method='post'>
<p>email <input type='text' name='email'></p>
<p>confirm email <input type='text' name='email2'></p>
<p>first name <input type='text' name='fname'></p>
<p>last name <input type='text' name='lname'></p>
<select id='gender' name='gender'>
<option value='1'>Male</option>
<option value='2'>Female</option>
</select>
<p>age <input type='text' name='age'></p>
<p>address <input type='text' name='address'></p>
<p>password <input type='password' name='password'></p>
<p>confirm pass <input type='password' name='password'></p>
<p>hint <input type='text' name='pass_hint'></p>
<p><input type='submit' name='submit' value='submit'></p>
</form>";
}

?>
</div>
</body>

最佳答案

至少有 2 个问题与您的代码无关,但是:

if ($_SESSION['logged_in']) {

还添加 isset()

<p>password <input type='password' name='password'></p>
<p>confirm pass <input type='password' name='password'></p>

您在这里没有密码2。

在我这边,通过删除 mysql 逻辑并添加旁路,我得到了在表单中输入的密码。

关于php - 我在提交帖子时不断收到 23750 作为密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20530104/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com