<?php
require 'core.inc.php';
require 'connect.inc.php';
if(!loggedin()){
if(
isset($_POST['username']) &&
isset($_POST['password']) &&
isset($_POST['password_again']) &&
isset($_POST['firstname']) &&
isset($_POST['surname'])
){
$username = $_POST['username'];
$password = $_POST['password'];
$password_hash = md5($password);
$password_again = $_POST['password_again'];
$firstname = $_POST['firstname'];
$surname = $_POST['surname'];
if(
!empty ($username) &&
!empty ($password) &&
!empty ($password_again) &&
!empty ($firstname) &&
!empty ($surname)
){
if($password == $password_again){
$query = "SELECT username FROM users WHERE username = '$username'";
$query_run = mysql_query($query);
if(mysql_num_rows($query_run)==1){
echo 'Sorry..! This user name '.$username.' already exist.<br/> <br>Pleasetry with any other.';
}else{
$query = "INSERT INTO users VALUES ('', '$username', '$password_hash','$firstname', '$surname')";
if($query_run = mysql_query($query)){
header('Location: register_success.php');
}
}
}else{
echo 'Password is not matching.<br> Please enter again same password.'
}
}else{
echo 'All fields are required. Thanks';
}
}
?>
<form action="register.php" method="POST">
Username:<br> <input type ="text" name="username" value = "<?php echo $username; ?>"><br><br>
Password:<br> <input type ="password" name="password"><br><br>
Password Again: <br> <input type="password" name="password_again"><br><br>
First Name:<br> <input type="text" name="firstname" value = "<?php echo $firstname; ?>"><br/><br>
Sur Name:<br> <input type="text" name="surname" value = "<?php echo $surname; ?>"><br><br>
<input type="submit" value="Register" >
</form>
<?php
}else if(loggedin()){
echo 'You\'re logged in.';
}
?>
我收到这些错误:注意:未定义索引:第 5 行 C:\xampp\htdocs\core.inc.php 中的 HTTP_REFERER
未定义变量:第46行C:\xampp\htdocs\register.php中的用户名注意:未定义变量:第49行C:\xampp\htdocs\register.php中的名字注意:未定义变量:第50行C:\xampp\htdocs\register.php中的姓氏