0
<?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
未定义变量:第46C:\xampp\htdocs\register.php中的用户名注意:未定义变量:第49C:\xampp\htdocs\register.php中的名字注意:未定义变量:第50C:\xampp\htdocs\register.php中的姓氏




4

1 回答 1

0
  1. HTTP Referer 是客户端控制的值,您的错误意味着您的浏览器没有设置它。

  2. register.php第 46 行,您正在使用一个名为username您未定义的变量

  3. 与第 2 点相同,在register.php第 49 行

  4. 与第 3 点相同,在register.php第 50 行

于 2013-05-11T16:09:41.827 回答