feat : dari suster
This commit is contained in:
parent
55b4edbe59
commit
3a17b7239b
34
login.html
Normal file
34
login.html
Normal file
@ -0,0 +1,34 @@
|
||||
<!-- index.html -->
|
||||
<!doctype html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>Halaman Login</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<main class="container" aria-live="polite">
|
||||
<h1>Masuk ke Akun Anda</h1>
|
||||
<p class="lead">Masukkan email dan kata sandi.</p>
|
||||
|
||||
|
||||
<form id="loginForm" novalidate>
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<input id="email" name="email" type="email" placeholder="name@contoh.com" required>
|
||||
<div class="error" id="emailError"></div>
|
||||
</div>
|
||||
|
||||
<div class="form-group password-row">
|
||||
<label for="password">Kata sandi</label>
|
||||
<input id="password" name="password" type="password" placeholder="Masukkan kata sandi" required minlength="6">
|
||||
<button type="button" class="toggle-pass" id="togglePass">Tampilkan</button>
|
||||
<div class="error" id="passError"></div>
|
||||
</div>
|
||||
<button id="submitBtn" type="submit">Masuk</button>
|
||||
<div id="result"></div>
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
45
login.php
Normal file
45
login.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
//untuk halaman login
|
||||
include "koneksi.php";
|
||||
if (isset($_POST['username']))
|
||||
{
|
||||
$username=$_POST['username'];
|
||||
}
|
||||
else $username ='';
|
||||
if (isset($_POST['password']))
|
||||
{
|
||||
$password=$_POST['password'];
|
||||
}
|
||||
else $password ='';
|
||||
if ($username!='' || $password!='')
|
||||
{
|
||||
$stmt = mysqli_prepare($conn,"select * from user where username=? and password=?");
|
||||
$enc=md5($password);
|
||||
mysqli_stmt_bind_param($stmt,"ss", $username,$enc);
|
||||
mysqli_stmt_execute($stmt);
|
||||
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
if ($row=mysqli_fetch_assoc($result))
|
||||
{
|
||||
echo "Login sukses";
|
||||
$_session['firstname'] = $row['firstname']; //simpan session firstname
|
||||
$_session['lastname'] = $row['lastname'];
|
||||
header("Location:dashboard.php"); //untuk pindah ke halaman dashboard.php
|
||||
|
||||
echo "firstname:".$row['firstname']."<br>";//kalo di file yang sama
|
||||
echo "lastname:".$row['lastname']."<br>";
|
||||
}
|
||||
else echo "Username/password salah";
|
||||
}
|
||||
?>
|
||||
|
||||
<html>
|
||||
<body>
|
||||
<form method="POST">
|
||||
Username: <input type="text" name="username"><br>
|
||||
Password:<input type="password" name="password"><br>
|
||||
<input type="submit">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user