dtv11049 2018-08-29 15:28
浏览 20

成功后登录页面不重定向,PHP [重复]

This question already has an answer here:

So hi guys. I need help in connecting my login page to process inputs and move to another window. I am fairly new in PHP and I have been doing this project by following some tutorials. I guess I got lost and mixed up my code. Kindly could someone like show me where I might be wrong? Thanks

<?php
include("includes/checklogin.php");
?>

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Login Page</title>
  <link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
  <div class="loginbox">
    <img src="images/matatu.png" class="matatu">
    <form action="landing page.php" method="POST">
      <p>Username</p>
      <input type="text" id="username" name="username" placeholder="Enter Username">
      <p>Password</p>
      <input type="password" id="password" name="password" placeholder="Enter Password">
      <input type="submit" name="" placeholder="Login">
      <a href="#">Forgot your password?</a></form><br>
    <a href="registration.php">Don't have an account?</a><br>
  </div>
  <div class="footer">
    <p>&copy 2018</p>
  </div>
</body>

</html>



<?php
$error=''; //Variable to Store error message;
if(isset($_POST['submit'])){
    if(empty($_POST['username']) || empty($_POST['password'])){
        $error = "Username or Password is Invalid";
    }
    else
    {
        //Define $user and $pass
        $user=$_POST['username'];
        $pass=$_POST['password'];
        //Establishing Connection with server by passing server_name, user_id and pass as a parameter
        $conn = mysqli_connect("localhost", "root", "Safaricom2017");
        //Selecting Database
        $db = mysqli_select_db($conn, "ticketing_system");
        //sql query to fetch information of registerd user and finds user match.
        $query = mysqli_query($conn, "SELECT * FROM admin WHERE password='$pass' AND username='$user'");

        $rows = mysqli_num_rows($query);
        if($rows == 1){
            header("Location: landing page.php"); // Redirecting to other page
        }
        else
        {
            $error = "Username of Password is Invalid";
        }
        mysqli_close($conn); // Closing connection
    }
}

?>
</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)
    • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。