2019-02-04 22:33
浏览 171

如何在php和JavaScript中重定向php Window.location.href或方法

I follow up a tutorial to learn more about php, in it's source code there is something which seems works at that time but not anymore. here is the code , please let me know what should i change in the code in order to make login process work (currently after entering a valid user name and pass and clicking login it freezes and show first page and not go to home.php

here is template/header.php:

<div class="container">
        <!--Head wrap starts-->
        <div id="head_wrap">
            <!--Header starts-->
            <div id="header">
                <img src="images/logo.png" style="float:left;"/>
                <form method="post" action="" id="form1">
                    <input type="email" id="email" name="email" placeholder="Email" required="required" />
                    <input type="password" id="pass" name="pass" placeholder="****" required="required"/>
                    <button type="submit" id="login">Login</button>
            <!--Header ends-->

here is login.php




        $email = mysqli_real_escape_string($con,$_POST['email']);
        $pass = mysqli_real_escape_string($con,$_POST['pass']);

        $get_user = "select * from users where user_email='$email' AND user_pass='$pass'";

        $run_user = mysqli_query($con,$get_user);

        $check = mysqli_num_rows($run_user);

                $email = mysqli_real_escape_string($con,$_POST['email']);


                        echo "<script>'home.php','_self')</script>";

            else {
            echo "<script>alert('Passowrd or email is not correct!')</script>";


please note i have tried

        echo "<script> window.location.href = 'home.php';</script>";

instead of

        echo "<script>'home.php','_self')</script>";

and still doesn't work, since it's tutorial and i have search through stackoverflow can't find any answer i appreciate your help.

4条回答 默认 最新

相关推荐 更多相似问题