dsfadsa08911 2016-03-21 16:39
浏览 51
已采纳

PHP-登录帐户工作

its my first time creating a login page. I want users to login, then the page redirects to the customer account page, if they have a account. I have added echo's so i can see whats happening. I have a "Logged in successfully" alert that works perfectly when i login. The page just does not redirect.

HTML

 <section class="container">
        <form id="myform " class="Form" method="post" action="login.php" accept-charset="utf-8">

            <!--                    <div id="first">-->
            <input type="email" id="email" name="email" placeholder="Email Address" value='' required>  
            <input class ="login-field" type="password" id="pass1" name="pass1" value="" placeholder="Password"  maxlength="30" required>
            <input type="submit" name="login" value="login"  class="btn ">
            <br>
        </form>

PHP

 <?php
 session_start();
 require ('./mysql.inc.php');
 ?>

 <?php
        if (isset($_POST['login']))

        //database varianbles
        $c_email = $_POST['email'];
        $c_password = $_POST['pass1'];

        // select login details
        $sel_c = "SELECT * FROM Cus_Register WHERE Cus_Email='$c_email' AND     Cus_Password='$c_password'";

        $run_c = mysqli_query($dbc, $sel_c);
        //check if customer is on databse
        $check_customer = mysqli_num_rows($run_c);


        if ($check_customer == 0) {
            echo "<script> alert('password or email is incorrect please try again')</script>";
         exit(); 
         }
           else{
            $_SESSION['Cus_Email'] = $c_email;
            echo "<script> alert ('Logged in successfully')</script>";
            echo "<script>window.open('./customer/Cus_Account.php'.'_self')          </script>";
        }
    ?>
  • 写回答

2条回答 默认 最新

  • dspym82000 2016-03-21 16:43
    关注

    Do you intend window.open('./customer/Cus_Account.php'.'_self') to be window.open('./customer/Cus_Account.php', '_self')?

    window.open takes a location and a target parameter and in JavaScript parameters are separated by a comma, not a full stop. In this case './customer/Cus_Account.php' is the location and '_self' is the target.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 请问如何在openpcdet上对KITTI数据集的测试集进行结果评估?
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗