Created
June 24, 2018 12:27
-
-
Save Techgokul/1b6b4d01c82c945a3157967cb478fffd to your computer and use it in GitHub Desktop.
Create login form using php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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