-1

我的项目中有问题,当我使用 DevServer 17 运行它时不起作用,但是当我使用 xampp 时它起作用了.. 问题和问题是我想知道为什么这只发生在那个项目中,特别是我的这一部分代码

xampp中,代码可以正常工作并与 db 连接,但在Devserver中,它将在代码末尾显示页面 _403.html(错误页面)。

有什么想法吗?

<?php

require_once ('database_connection.inc');
$statement = $connect->prepare("SELECT user_id FROM all_user WHERE email = ?");
$statement->execute(array( corection("email") ) );
if( $statement->rowCount() > 0 ){
    session_start();
    $_SESSION['err']="email Exist";
    $_SESSION['mailo'] = corection("email");
    header('location:login_err.php');
    exit;
}
else if(!($_SERVER['REQUEST_METHOD'] == 'POST') || ! isset($_POST["subscribe"]) ):
    header("location:../erreur/_403.html");
    exit;
else:

    $test = false || vide("email") ;
    $test = $test || vide("password");
    $test = $test || vide("Firstname");
    $test = $test || vide("Lastname");
    $test = $test || vide("gender"); 
    $test = $test || vide("year"); 
    $test = $test || vide("month"); 
    $test = $test || vide("day") ;
    
    if(!$test):

        $data = array(
            ':email'        =>  corection("email"),
            ':password'     =>  password_hash( corection("password") , PASSWORD_DEFAULT) ,
            ':first_name'   =>  corection("Firstname") ,
            ':last_name'    =>  corection("Lastname") ,
            ':sexe'         =>  corection("gender") ,
            ':berth_day'    =>  corection("year")  . "-" . corection("month") . "-" . corection("day"),
        );

        $query = "INSERT INTO all_user (email, password , first_name , last_name , berth_day ,sexe ) VALUES (:email, :password , :first_name , :last_name ,  :berth_day , :sexe )";

        
        $statement = $connect->prepare($query);

        if($statement->execute($data)):
            //login

            $statement = $connect->prepare(" SELECT * FROM all_user  WHERE email = :email ");
            $statement->execute( array( ':email' => corection("email") ) );
            if($statement->rowCount() > 0):
                session_start();
                $result = $statement->fetchAll();
                foreach($result as $row):
                    $_SESSION['user_id']    = $row['user_id'];
                    $_SESSION['email']      = $row['email'];
                    $statement = $connect->prepare("INSERT INTO login_details (user_id) VALUES ('".$row['user_id']."')");
                    $statement->execute();
                    $_SESSION['login_details_id'] = $connect->lastInsertId();
                    $_SESSION['etaConnt']   = $row['etaConnt'];
                    header('location:subscribe_3_valid_email.php');
                    exit;
                endforeach;
           endif;
        endif;
    endif;
endif;

header('location:../erreur/_403.html');

exit;

function corection($str){
    return trim(htmlspecialchars( $_POST[$str] ));
}

function vide($str){
    return empty($_POST[ $str ]);
}?>
4

1 回答 1

0

返回您的表单并确保其方法定义为 post。

于 2020-11-22T04:37:09.657 回答