drpmazn9021 2017-03-28 17:56
浏览 63

从签入的日志中获取数据,如果我按下刷新它将重定向到白页,它将转到它必须指向的页面

I am getting some information from the login page form.

When I press submit, it goes to a check-login.php page where there it checks from the database if the credentials are correct or wrong.
Then it redirects to a track page.

My problem is that when I press submit on the log in page with the correct credentials.
It redirects to a white page.
And then, if I press refresh, it redirects to the correct page.

<div>
  <h1>Login Form</h1>
  <form action="check-login.php">
    <input type="text" name="user" placeholder="user">
    <input type="password" name="password" placeholder="password">
    <input type="submit" value="log in">
  </form>
</div>

This is the check-login php page

<?php
session_start();
$user=$_GET['user'];
$pass=$_GET['password'];
include("dblogin.php");
$sql="SELECT * FROM login";
$result=mysql_query($sql);
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    if($user==$row["username"] && $pass==$row["password"]){
        $_SESSION["userid"]=$row["id"];
        header ("Location: tracks.php");
  }
}
if ($_SESSION["userid"]==""){
  header ('Location: login.html?message=Wrong Username or Password');
}
?>
  • 写回答

3条回答 默认 最新

  • dqwh1202 2017-03-28 18:17
    关注

    Try the following code to make a redirect:

    http_response_code(302); // send redirect code
    header('Location: /tracks.php'); // send Location header
    exit(0); // don't send anything else
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle触发器记录修改前后的字段值
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器