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条)

报告相同问题?

悬赏问题

  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行