How do I create an easy login script that does not require a database. I would like it to be safe.
Alright, what about this script, i just made it by my knowledge in php.
<?php
// Start session
session_start();
// Username and password
$ID = "admin";
$pass = "123456";
if (isset($_POST["ID"]) && isset($_POST["pass"])) {
if ($_POST["ID"] === $anvandarID && $_POST["pass"] === $pass) {
/
$_SESSION["inloggedin"] = true;
header("Location: safe_site.php");
exit;
}
// Wrong login - message
else {$wrong = "Bad ID and password, the system could not log you in";}
}
?>
The safe_site.php contains this and some content:
session_start();
if (!isset($_SESSION["inloggning"]) || $_SESSION["inloggning"] !== true) {
header("Location: login.php");
exit;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…