Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用户登录时重新定位php_Php - Fatal编程技术网

用户登录时重新定位php

用户登录时重新定位php,php,Php,当前正在创建一个html登录表单,该表单由保存在名为index.php的文件中的电子邮件地址和密码组成 在我的标记上方,我创建了相关的php脚本,以检查提供的信息是否与数据库中保存的信息相匹配 在执行少量if语句之后,我尝试使用header()函数将用户重定向到新页面 不过,这似乎不起作用,我很想知道为什么 我的HTML表单->formaction='index.php'将自身指向自身,因此我不确定这是否可能导致错误 我的HTML: <form action="index.php" met

当前正在创建一个html登录表单,该表单由保存在名为index.php的文件中的电子邮件地址和密码组成

在我的
标记上方,我创建了相关的php脚本,以检查提供的信息是否与数据库中保存的信息相匹配

在执行少量if语句之后,我尝试使用header()函数将用户重定向到新页面

不过,这似乎不起作用,我很想知道为什么

我的HTML表单->
formaction='index.php'
将自身指向自身,因此我不确定这是否可能导致错误

我的HTML:

<form action="index.php" method="POST"> 
    <table style="width:100%"> 
        <tr> 
            <th><input type="text" name="email" required placeholder="Email" /></th>
        </tr>
        <tr>
            <th><input type="password" name="password" required placeholder="Password" /></th>
        </tr>
            <tr>
        <th> <input class="button" id="sign-in-show" type="submit" value="Sign in" name="submit" /> </th>
        </tr>
        <tr> 
            <th> <p style="float:right; font-size:13px; margin-top:0px;"> <a href="">Forgot password?</a> </p> </th>
        </tr>           
    </table>
</form>

我还将发布我所有的php代码,因为只发布我的header()代码似乎有点毫无意义:

$conn = new mysqli($servername, $username, $password); 

        if($conn->connect_error) { 
            die ('Connection Failed'); 
        } else { 
            echo ('Connection Established <br>'); 

            if(!mysqli_select_db($conn,'Oreon')) { 
                die('Database could not be reached ' . $conn->error); 
            } else { 

                // First get the row containing the email address provided 
                $sign_in_token = "SELECT * FROM core_customer_information WHERE email='".$email."' LIMIT 1"; 

                $result = mysqli_query($conn, $sign_in_token); 

                // Check if the query has returned a row 
                if(mysqli_num_rows($result) == 1) 
                { 
                    // Store needed variables 
                    while($row = mysqli_fetch_assoc($result)) 
                    { 
                        $tempPassword = $row['password'];
                        $checkActivation = $row['activated']; 

                        // Check if the account has been activated 
                        if($checkActivation=='0') 
                        { 
                            die('Your account has not yet been activated');
                        } 

                        // Check if password matches hashed crypted password 
                        else if (password_verify($user_password, $tempPassword)) 
                        {
                            $_SESSION['sessionEmail'] = $email;
                            header('Location: http://www.google.com'); 
                            exit(); 
                        }
                    }
                } 

                else 
                { 
                    die ("Incorrect email address or password: " . $conn->error); 
                }
            } // close brackets db selected 
        }
    }
$conn=newmysqli($servername、$username、$password);
如果($conn->connect_error){
die(“连接失败”);
}否则{
echo(‘已建立连接’
); 如果(!mysqli_select_db($conn,'Oreon'){ die('无法访问数据库。$conn->错误); }否则{ //首先获取包含提供的电子邮件地址的行 $sign_in_token=“从核心客户信息中选择*,其中email=”“$email。”“限制1”; $result=mysqli\u查询($conn,$sign\u in\u令牌); //检查查询是否返回了一行 if(mysqli_num_rows($result)==1) { //存储所需的变量 while($row=mysqli\u fetch\u assoc($result)) { $tempPassword=$row['password']; $checkActivation=$row['activated']; //检查帐户是否已激活 如果($checkActivation='0') { 死亡(“您的帐户尚未激活”); } //检查密码是否与哈希加密的密码匹配 else if(密码\u验证($user\u密码,$tempPassword)) { $\会话['sessionEmail']=$电子邮件; 标题('位置:http://www.google.com'); 退出(); } } } 其他的 { die(“不正确的电子邮件地址或密码:.$conn->错误); } }//关闭选定的数据库 } }
目前,我正试图重定向到谷歌只是为了测试的目的

如果有人能帮助我,我将不胜感激


提前感谢(很抱歉不得不发布我所有的代码)

您检查了错误日志了吗?您假设查询正在工作。请记住,在发送任何实际输出之前,必须调用header(),无论是通过普通HTML标记、文件中的空行还是从PHP。使用include或require函数或其他文件访问函数读取代码,并在调用header()之前输出空格或空行,这是非常常见的错误。使用单个PHP/HTML文件时也存在同样的问题。啊,救生员@ManosForsaken我在呼应什么。谢谢你。非常感谢!!!!