Skip to content

Instantly share code, notes, and snippets.

@ridoansaleh
Created December 2, 2017 09:11
Show Gist options
  • Save ridoansaleh/cd34c4ba07b53cdd1d8776fae7508dad to your computer and use it in GitHub Desktop.
Save ridoansaleh/cd34c4ba07b53cdd1d8776fae7508dad to your computer and use it in GitHub Desktop.
<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
</head>
<body>
<form action="" method="post">
<h2>Login here..</h2>
Username : <input type="text" name="user">
<br>
Password : <input type="password" name="pass">
<br>
<input type="submit" name="login" value="Login">
</form>
<?php
if(isset($_POST['login'])){
$user = $_POST['user'];
$pass = $_POST['pass'];
echo $_POST['user'];
//- periksa login
if($user == "admin" && $pass == "1234"){
$_SESSION["login"] = $user;
//- menuju ke halaman selanjutnya
echo "<h1>Anda berhasil LOGIN</h1>";
echo "<h2>Klik <a href='session2.php'> di sini (session2.php) </h2>";
}
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment