Upload New File

parent 3c5c2ad2
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="public/css/login.css">
<link rel="icon" type="image/png" href="public/img/logo2.png" />
<title>Login Page</title>
</head>
<body>
<?php
// fungsi inputan karakter
function input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
//cek apakah ada kiriman dari method post?
if($_SERVER["REQUEST_METHOD"] == "POST") {
session_start();
// if (!isset($_SESSION["username"])){
// echo "<script>alert('Login terlebih dahulu');window.location='index.php';</script>";
// exit;
// // echo "Anda harus login dulu <br><a href='login.php'>Klik disini</a>";
// exit;
// }
include('common/dbconfig.php');
$username = input($_POST["username"]);
$password = input($_POST["password"]);
$query = "SELECT * FROM log_akun WHERE username='".$username."' and password='".$password."' limit 1";
$hasil1 = mysqli_query($koneksi,$query);
$jumlah = mysqli_num_rows($hasil1);
if($jumlah>0){
$row = mysqli_fetch_assoc($hasil1);
$_SESSION["id_akun"]=$row["id_akun"];
$_SESSION["nama"]=$row["nama"];
$_SESSION["email"]=$row["email"];
$_SESSION["alamat"]=$row["alamat"];
$_SESSION["j_kelamin"]=$row["j_kelamin"];
$_SESSION["username"]=$row["username"];
$_SESSION["password"]=$row["password"];
$_SESSION["role"]=$row["role"];
if($_SESSION["role"]=$row["role"]=="admin"){
header("Location:admin/index.php");
$_SESSION['is_login'] = TRUE;
}else if($_SESSION["role"]=$row["role"]=="user"){
header("Location:user/index.php");
$_SESSION['is_login'] = TRUE;
}else{
header("Location:index.php");
}
}else{
echo "<script>alert('Username dan password salah');window.location='index.php';</script>";
}
}
?>
<h1>Selamat Datang di <br/> Travel OK</h1>
<div class="kotak_login">
<center>
<img src="public/img/logo3.png" width="100px;">
</center>
<form action="<?= $_SERVER["PHP_SELF"]; ?>" method="post">
<label>Username</label>
<input type="text" name="username" class="form_login" placeholder="Username .." >
<label>Password</label>
<input type="password" name="password" class="form_login" placeholder="Password ..">
<input type="submit" name="login" class="tombol_login" value="MASUK"><br>
<a href="register.php"> <input type="button" name="register" class="tombol_register" value="DAFTAR"></button> </a>
</center>
</form>
</div>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment