Last active
September 27, 2018 11:14
-
-
Save fannyhasbi/a4281446fb98d727b2af1fd75ddb9d36 to your computer and use it in GitHub Desktop.
Dasar halaman login
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 | |
if(isset($_POST['login'])){ | |
$username = $_POST['username']; | |
$password = $_POST['password']; | |
require_once "./koneksi.php"; | |
$sql = "SELECT * FROM user WHERE username = '$username'"; | |
$query = mysqli_query($connect, $sql); | |
$result = mysqli_fetch_assoc($query); | |
if(password_verify($password, $result['password'])){ | |
session_start(); | |
$_SESSION['login'] = true; | |
$_SESSION['username'] = $result['username']; | |
header('Location: ./index.php'); | |
} | |
else { | |
die('Username atau password salah'); | |
} | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Mashook</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> | |
</head> | |
<body> | |
<div class="container-fluid"> | |
<div class="jumbotron alert-info text-center"> | |
<h1>Mashook</h1> | |
</div> | |
<div class="row"> | |
<div class="col-md-4 col-md-offset-4"> | |
<form action="" method="post"> | |
<div class="form-group"> | |
<label for="username" class="control-label">Username</label> | |
<input type="text" name="username" class="form-control"> | |
</div> | |
<div class="form-group"> | |
<label for="password" class="control-label">Password</label> | |
<input type="password" name="password" class="form-control"> | |
</div> | |
<div class="form-group"> | |
<input type="submit" name="login" class="btn btn-success" value="Login"> | |
</div> | |
</form> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment