我正在使用注册登录系统。当我点击注册时,它没有显示任何结果。它只是刷新页面。似乎isset
无法正常工作。是否有其他方法可以做到这一点?
<?php
require 'core.inc.php';
require 'connect.inc.php';
if(!loggedin()) {
$check_array =
array('username','password','password_again','firstname','surname');
if(!array_diff($check_array,array_keys($_POST))) {
$username = $_POST['username'];
$password = $_POST['password'];
$password_again = $_POST['password_again'];
$firstname = $_POST['firstname'];
$surname = $_POST['surname'];
if(!empty($username) && !empty($password) && !empty($password_again) &&
empty($firstname) &&!empty($surname)) {
echo 'Ok.';
}
else {
echo 'All fields are required.';
}
}
else echo 'no.';
?>
<form action="register.php" method="POST">
Username:<br><input type ="text" name="username"><br>
Password:<br><input type ="password" name= "password"><br>
Password again:<br><input type="password" name="password_again"><br>
Firstname:<br><input type="text" name="firstname"><br>
Surname:<br><input type="text" name="Surname"><br><br>
<input type="submit" value= "Register"><br>
</form>
<?php
}
else if(loggedin()) {
echo 'You\'re already registered.';
}
?>
答案 0 :(得分:0)
你有一个错字。这一行 -
if(!empty($username) && !empty($password) && !empty($password_again) &&
empty($firstname) &&!empty($surname)) {
应该是
if(!empty($username) && !empty($password) && !empty($password_again) &&
!empty($firstname) &&!empty($surname)) {
^ // **missed this**
另外,根据Sean的评论,你的html更改name='surname'
。
答案 1 :(得分:0)
将def foo(afile):
header=None
for line in afile:
strings = line.split(delimiter)
if len(strings)==1:
header = strings[0]
else:
line = delimiter.join([header]+strings)
yield line
with open(filename) as f:
A = np.loadtxt(foo(f),....)
更改为Surname
,因为您使用的是surname
$_POST['surname'];
答案 2 :(得分:0)
<?php
require 'core.inc.php';
require 'connect.inc.php';
if(!loggedin()) {
$check_array =
array('username','password','password_again','firstname','surname');
if(!array_diff($check_array,array_keys($_POST))) {
$username = $_POST['username'];
$password = $_POST['password'];
$password_again = $_POST['password_again'];
$firstname = $_POST['firstname'];
$surname = $_POST['surname'];
if(!empty($username) && !empty($password) && !empty($password_again) &&
!empty($firstname) && !empty($surname)) {
echo 'Ok.';
}
else {
echo 'All fields are required.';
}
}
else echo 'no.';
?>
<form action="register.php" method="POST">
Username:<br><input type ="text" name="username"><br>
Password:<br><input type ="password" name= "password"><br>
Password again:<br><input type="password" name="password_again"><br>
Firstname:<br><input type="text" name="firstname"><br>
Surname:<br><input type="text" name="surname"><br><br>
<input type="submit" value= "Register"><br>
</form>
<?php
}
else if(loggedin()) {
echo 'You\'re already registered.';
}
?>