Skip to content

Instantly share code, notes, and snippets.

@Techgokul
Created June 24, 2018 12:27
Show Gist options
  • Save Techgokul/1b6b4d01c82c945a3157967cb478fffd to your computer and use it in GitHub Desktop.
Save Techgokul/1b6b4d01c82c945a3157967cb478fffd 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