PHP登录页面无效

时间:2018-04-09 16:26:04

标签: php html mysql mysqli

当我提交注册用户信息时,用户可以注册他们的帐户但没有任何反应(没有错误出现,登录后没有重定向)。

如果有人可以帮我解决,我已经在下面发布了我的表单部分代码以及我的Login.php文件?我玩过代码,看看是否有任何特定的阻止页面功能,但似乎没有什么区别

登录表格     

<body>  
    <div align = "center" ><p style="margin-top: 100px;">
        <div class="col-lg-4 mb-4">
            <div class="card h-100">
                <h4 class="card-header"><font face = "Lucida 
                     Handwriting">Login</font></h4>
                <form method="post" action="<?php echo 
                    htmlspecialchars($_SERVER["PHP_SELF"]);?>"><b

                <p style="margin-top: 50px;"></p>
                <span class="error">* <?php echo $email_addressErr;?></span>
                    Email Address:<br><input type="text" 
                    name="email_address" 
                    value="<?php echo $email_address;?>"><br>

                <span class="error">* <?php echo $acc_passwordErr;?></span>
                    Password:<br><input type="text" name="acc_password" 
                    value=" 
                <?php echo $acc_password;?>"><br>

                <br><p style="margin-top: 30px;"></p>
                <input type ="submit" value="submit" name="Sign-In" 
                     href="Main.php"></p> 
                </form>
            </div>
        </div>
    </div>
</body>

主页

<html lang="en">

    <?php

        include 'Assets/Partials/Header.php'
    ?>
    <?php

        //start session
        session_start();
        //if userSession is set
        if ( isset($_SESSION['userSession'])!="" ) 
        {
            header("Location: Main.php");
        }
        require_once 'DBConnect.php';

        //initialising variables
        $email_address = "";
        $acc_password = "";     

        //if login button is clicked
        if (isset($_POST['Sign-In']) ) 
        {
            //Following 3 lines commented out and they weren't doing 
              anything
            //$email_address = strip_tags($_POST['email_address']);  
            //$email_address = $mysqli->strip_tags($_POST['email_address']);

            // $acc_password = strip_tags($_POST['acc_password']);

            $email_address = $DBcon->mysqli_real_escape_string($DBcon, 
            $_POST['email_address']);
            $acc_password = $DBcon->mysqli_real_escape_string($DBcon, 
            $_POST['acc_password']);

            //select user details where email matches email field
            $query = $DBcon->query("SELECT customer_id FROM customer WHERE 
            email_address='$email_address' and acc_password = 
            '$acc_password'");
            $result  = mysqli_query($DBcon, $query);
            $row = mysqli_fetch_arry($result, MYSQLI_ASSOC);
            $active = $row['active'];

            //see if row is returned
            $count = mysqli_num_rows($result); 

            //if row is returned and hashed password is verified, set 
              session
            if ( password_verify($acc_password, $row['acc_password']) && 
                 $count==1 ) 
            {
                $_SESSION['userSession'] = $row['customer_id'];
                header("Location: Main.php");
            }
            //else notify user that email or password is incorrect
            else 
            {
            echo"<script>alert('Your Email Address and/or Password is 
            invalid')</script>";
            }
            //close connection
            $DBcon->close();
        }//End If
    ?>


    <body>

        <?php
            include 'Assets/Partials/IndexMenu.php'
        ?>

        <?php
            include 'Assets/Partials/LoginForm.php'
        ?>

    </body>

</html>

0 个答案:

没有答案