55 lines
1.6 KiB
PHP
55 lines
1.6 KiB
PHP
<?php
|
|
session_start();
|
|
include "koneksi.php";
|
|
|
|
if(isset($_POST['username'])) {
|
|
$username = $_POST['username'];
|
|
$password = md5($_POST['password']);
|
|
|
|
$query = mysqli_query($koneksi, "SELECT * FROM user WHERE username='$username' AND password='$password'");
|
|
|
|
if(mysqli_num_rows($query) > 0){
|
|
$data = mysqli_fetch_array($query);
|
|
$_SESSION['user'] = $data;
|
|
echo '<script>alert("Welcome, '.$data['nama'].'");
|
|
location.href="esp-outputs.php";</script>';
|
|
} else {
|
|
echo '<script>alert("Username/password does not match.");</script>';
|
|
}
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Login to the website</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="stylesheet" type="text/css" href="style.css">
|
|
</head>
|
|
<body>
|
|
<form method="post">
|
|
<table align="center">
|
|
<tr>
|
|
<td colspan="2" align="center">
|
|
<h3>Login User</h3>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Username </td>
|
|
<td><input type="text" name="username" required></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Password </td>
|
|
<td><input type="password" name="password" required></td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>
|
|
<button type="submit">Login</button>
|
|
<p>No Account? <a href="regis.php">Register Here</a></p>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
</body>
|
|
</html>
|