Skip to content

Instantly share code, notes, and snippets.

@melanyss
Forked from Techgokul/index1.php
Created May 19, 2020 12:46
Show Gist options
  • Save melanyss/830c734dac235f13d206085efecf61bb to your computer and use it in GitHub Desktop.
Save melanyss/830c734dac235f13d206085efecf61bb to your computer and use it in GitHub Desktop.
Create login form using php
<!DOCTYPE html>
<html>
<?php
session_start();
$username= "admin";
$password= "password";
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == false) {
header("Location: success.php");
# code...
}
if (isset($_POST['username']) && isset($_POST['password'])) {
$_SESSION['loggedin'] = true;
header("Location: success.php");
# code...
}
?>
<head>
<title>Login page</title>
</head>
<body>
<form method="post" action="index1.php">
Username:<br>
<input type="text" name="username"><br>
Password:<br>
<input type="password" name="password"><br>
<input type="submit" value="Login!" >
</form>
</body>
</html>
<?php
session_start();
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == false) {
header("Location: index1.php");
}
?>
<h2>Your'e logged in successfully into our server.</h2>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment