<?php
require_once("Includes/db.php");
$logonSuccess = true;
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(FifaDB::getInstance()->verify_login($_POST["user"], $_POST["userpassword"] == 1)){
session_start();
$_SESSION["user"] = $_POST["user"];
header('Location: home.php');
} else {
$logonSuccess = false;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<form name="logon" action="index.php" method="POST" >
Username: <input type="text" name="user"/>
Password <input type="password" name="userpassword"/>
<?php
if (!$logonSuccess)
echo "Invalid name and/or password";
?>
<input type="submit" value="Login"/>
</form>
</body>
</html>
In the context of this code, please explain:
if($_SERVER["REQUEST_METHOD"] == "POST")
and
header('Location: home.php');
Is there alternatives to this? Also, if i want the page to reload the same page after being logged in what would i change in the code to do that?
Thanks 🙂