dongtu0363 2016-06-01 12:42
浏览 11
已采纳

PHP无法检查输入并跳转到下一页[重复]

This question already has an answer here:


I try to get this login page running.
My problem is that i never reach the line:

header("location: questions1.php");

Im pretty sure its the if() but i tried many things and nothing is working.
My loggin is fine. I just wanna check that there is somthing in mail and pw and than go to the next page.

<!DOCTYPE html>
<html lang="de">
<head>
    <title>Login</title>
</head>
<body>
<div content="php">
    <?php
    if (isset($_POST['login']) && !empty($_POST['mail']) && !empty($_POST['pw'])) {
        header("location: questions1.php");
    }
    ?>
</div>
<form action="" method="post">
    <p>E-Mail:<input type="text" name="mail" required/></p>
    <p>Password:<input type="password" name="pw" required/></p>
    <button type="submit" name="login">Login</button>
</form>
</body>
</html>

The header line works well i set the if to true but i need to check if mail and pw are set befor.

</div>
  • 写回答

1条回答 默认 最新

  • doushi3202 2016-06-01 12:57
    关注

    Try
    Removed ./ From ./connect.php

    <?php
        if (isset($_POST['login']) && !empty($_POST['mail']) && !empty($_POST['pw'])) {
    
        include $_SERVER['DOCUMENT_ROOT'] . './connect.php';
        $sql = "SELECT userdb.Email,userdb.Password FROM userdb";
        $s = $pdo->prepare($sql);
        $s->execute();
        header("location: questions1.php");
    }
    ?>
    
    <!DOCTYPE html>
    <html lang="de">
    <head>
      <title>Login</title>
    </head>
       <body>
    
         <form action="" method="post">
          <p>E-Mail:<input type="text" name="mail" required/></p>
          <p>Password:<input type="password" name="pw" required/></p>
          <button type="submit" name="login">Login</button>
     </form>
       </body>
    </html>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊