http://170.178.197.250/~devdegree/index.php
使用phpacademy的表格,随时访问临时网址,希望在这里对我有所帮助。
问题是有一个有效的数据库连接到这个网站,我输入字段,它只是停留在寄存器.php文件中。
当我从数据库本身创建用户然后使用该信息登录时,同样适用,同样的问题再次适用。
这是大约 2 年的历史,去年它对我有用,如果您需要查看任何文件,如果需要,我会在这里回复脚本,但希望它足够了。
注册.php
<?php
include 'core/init.php';
logged_in_redirect();
include 'includes/overall/header.php';
if (empty($_POST) === false) {
$required_fields = array('username', 'password', 'password_again', 'first_name', 'email');
foreach($_POST as $key=>$value) {
if (empty($value) && in_array($key, $required_fields) === true) {
$errors[] = 'Fields marked with an asterisk are required';
break 1;
}
}
if (empty($errors) === true) {
if (user_exists($_POST['username']) === true) {
$errors[] = 'Sorry, the username ''' . $_POST['username'] . ''' is already taken';
}
if (preg_match("/''s/", $_POST['username']) == true) {
$errors[] = 'Your username must not contain any spaces.';
}
if (strlen($_POST['password']) < 6) {
$errors[] = 'Your password must be at least 6 characters';
}
if ($_POST['password'] !== $_POST['password_again']) {
$errors[] = 'Your passwords do not match';
}
if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) {
$errors[] = 'A valid email address is required';
}
if (email_exists($_POST['email']) === true) {
$errors[] = 'Sorry, the email ''' . $_POST['email'] . ''' is already in use';
}
}
}
?>
<h1>Register</h1>
<?php
if (isset($_GET['success']) === true && empty($_GET['success']) === true) {
echo 'You''ve been registered successfully! Please check your email to activate your account.';
} else {
if (empty($_POST) === false && empty($errors) === true) {
$register_data = array(
'username' => $_POST['username'],
'password' => $_POST['password'],
'first_name' => $_POST['first_name'],
'last_name' => $_POST['last_name'],
'email' => $_POST['email'],
'email_code' => md5($_POST['username'] + microtime())
);
register_user($register_data);
header('Location: register.php?success');
exit();
} else if (empty($errors) === false) {
echo output_errors($errors);
}
?>
<form action="" method="post">
<ul>
<li>
Username*:<br>
<input type="text" name="username">
</li>
<li>
Password*:<br>
<input type="password" name="password">
</li>
<li>
Password again*:<br>
<input type="password" name="password_again">
</li>
<li>
First name*:<br>
<input type="text" name="first_name">
</li>
<li>
Last name:<br>
<input type="text" name="last_name">
</li>
<li>
Email*:<br>
<input type="text" name="email">
</li>
<li>
<input type="submit" value="Register">
</li>
</ul>
</form>
<?php
}
include 'includes/overall/footer.php'; ?>
同样,任何其他文件(大约有 20+),然后我会看看向您展示是否意味着您可以理解并帮助我。
非常感谢,
开发。
我看不到您的表格action
到register.php
.尝试添加一个类似" action="register.php"
"
从当前网站上查看您正确链接的表单帖子以注册.php。没有什么是不起作用的。您应该检查机器中的httpd(或您使用的任何内容)日志。也许 php 的一些警告或一些致命错误可以解释这个问题。从此代码和网站来看,没有任何问题。