login.php
This commit is contained in:
parent
9bc9e4f796
commit
b38f8b4923
45
login.php
45
login.php
@ -1,45 +0,0 @@
|
|||||||
<?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