How do i redirect a php login file back to index.html presented with a message 'Welcome User'

Barry

New Member
#1
My work codes but the message is not showing up after clicking login. It does redirect for 5 second but does not show the appropriate message 'Welcome User'
Mã:
$error = "";
$success = "";

//  username: user password: pass
if (isset($_POST["submit"])) {
  $username = $_POST['username'];
  $password = $_POST['pass'];
  if ($username == "user") {
    if ($password == "pass") {
      $error = "";
      $success = "Welcome user!";
      header('Location: index.php');
      sleep(5);
    }
    else {
      $error = "Wrong Password!";
      $success = "";
    }
  }
  else {
      $error = "Wrong Username!";
      $success = "";
  }
}
 

Admin

Administrator
Thành viên BQT
#2
You could use Session variables if you don't want to pass the message via URL.
 

Từ khóa phổ biến

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Chủ Đề Xem Nhiều

Top