doujingxi3356 2013-11-20 16:17
浏览 838

成功登录/或登录失败后重定向

for my page I created a login. It works all as planned, but how do I make it redirect to another page automatically when the login was successfull and to a different page when it was not?

Different topic, I am new to this page, how do I make four spaces for the quote automatically? Putting four spaces manually in front of each line seems a bit weird. Thanks for any help :) Chris

    <?php session_start()?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>checklogin</title>
</head>

<body>

<?php
$con = mysqli_connect("mysql.freehostingnoads.net","u291_admin","...","u291_login");
if (mysqli_connect_errno($con))
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }



$sql= "SELECT * FROM login_data";
$result= mysqli_query ($con, $sql);
$row= mysqli_fetch_array($result);
if($row["username"] == $_POST["user"] && $row["password"] == $_POST["pwd"]){

    $_SESSION['username'] =$_POST["user"];


    echo "You succesfully logged in";
   echo '<br /> If you are not redirected automatically please click <a href="showdata.php">here</a>';
    //header("location:hidden.php");


}
else
{   echo "Wrong username or password";
    // header("location: www./index.html");
}



?>  

</body>
</html>
  • 写回答

5条回答 默认 最新

  • dso89762 2013-11-20 16:18
    关注

    You have already found

    header("location:index.html");
    

    But the problem is, your headers are already sent. You shouldn't echo anything before this.

    评论

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services