我的php代码将我发送到空白页面,并显示了我的php文件的名称

时间:2018-11-29 20:16:13

标签: php forms mysqli prepared-statement

这以前工作过,现在我只是修改了一个名为country的变量,但它不起作用。

当我从html代码中点击“注册”按钮时,它会将我发送到地址为www.mysite / signup.php的空白页面

这是我的代码,希望您能帮助我解决这个问题:

  <?php 

 if(isset($_POST['signup']))
 {
     require 'dbh-inc.php';
     $email = $_POST['email'];
     $password = $_POST['password'];
     $fullname = $_POST['fullname'];
     $country = $_POST['country'];
     $passwordRepeat = $_POST['pwd-repeat'];
     $parentEmail= $_POST['parentEmail'];
     $users = $_POST['username'];

     if(empty($email) || empty($password) || empty($fullname) || empty($country) || empty($passwordRepeat) || empty($users))
     {
         header("Location: ../index.html?error=emptyFields");
         exit();
     }
     else if(!filter_var($email,FILTER_VALIDATE_EMAIL))
     {
          header("Location: ../index.html?error=emailWrong");
         exit();
     }

     else if($password != $passwordRepeat)
     {
         header("Location: ../index.html?error=passwordCheck");
         exit();
     }
     else {
         $sql = "SELECT username FROM member WHERE username=?";
         $stmt = mysqli_stmt_init($conn);
         if(!mysqli_stmt_prepare($stmt,$sql)){
              header("Location: ../index.html?error=sqlError");
         exit();
         }
         else{
             mysqli_stmt_bind_param($stmt, "s", $users);
             mysqli_stmt_execute($stmt);
             mysqli_stmt_store_result($stmt);
             $resultCheck = mysqli_stmt_num_rows($stmt);
             if($resultCheck>0){
                 header("Location: ../index.html?error=usernameExists");
         exit();
             }
             else {
                 $sql = "INSERT INTO member (fullname,email,password_hash,parentEmail,country,username) VALUES (?,?,?,?,?,?)";
                 $stmt = mysqli_stmt_init($conn);
                 if(!mysqli_stmt_prepare($stmt,$sql)){
                     if(!mysqli_stmt_prepare($stmt,$sql)){
              header("Location: ../index.html?error=sqlError");
         exit();
                 }
                     else{
                            $passwordHash = password_hash($password, PASSWORD_DEFAULT);
                            mysqli_stmt_bind_param($stmt, "sssss", $fullname, $email,$passwordHash,$parentEmail,$country,$username);
                            mysqli_stmt_execute($stmt);
                            header("Location: ../index.html?signup=succes");
                            exit();
                     }
             }

         }
     }
 }
 }
?>

我还让字段为空以查看if语句是否起作用,或者我引入了不同的密码或错误的电子邮件,它们正在起作用,但是如果我引入的所有正确信息都没有,那么

0 个答案:

没有答案