Claudia Cristovani c80db110d2 initial commit
2025-11-17 13:43:00 +07:00

45 lines
1.1 KiB
PHP

<?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>