Skip to content
Snippets Groups Projects
Commit 530ced36 authored by Mikhael Artur Darmakesuma's avatar Mikhael Artur Darmakesuma
Browse files

Login feature added

parent e96958b3
1 merge request!42Projekers - 13515051 - Girvandi Ilyas
<?php
echo "login controller";
\ No newline at end of file
......@@ -5,8 +5,9 @@ function hideMe(i){
var inputBox = document.getElementById("locationinput"+i);
var image = document.getElementById("imageeditsave"+i);
if(textHidden){
if(inputBox.type=="hidden"){
textBox.setAttribute("style","display:none");
inputBox.type = "text";
inputBox.setAttribute("style","display:block");
inputBox.value = textBox.innerHTML;
image.src = "../img/floppy.png";
......
......@@ -18,6 +18,15 @@ class User {
mysqli_close($con);
return $result;
}
function getUserByLogIn($username, $password){
$con = mysqli_connect('localhost','root','','projekers');
mysqli_select_db($con, 'projekers');
$sql = "SELECT * FROM user WHERE username='" . (string)$username . "' AND password='" . (string)$password . "'";
$result = mysqli_query($con, $sql);
mysqli_close($con);
return $result;
}
function getUserById($id){
$con = mysqli_connect('localhost','root','','projekers');
......
<html>
<head>
<title>Projekers - Login</title>
<link rel = "stylesheet" href = "../css/primary.css">
<link rel = "stylesheet" href = "../css/index.css">
</head>
<body>
<div class = "container">
<div>
<div class = "horizontal"></div>
<div class = "judul">LOGIN</div>
<div class = "horizontal"></div>
</div>
<div class = "form_input">
<form>
<div class="set">
<div class="label">Username</div>
<div class="field"><input type = "text"></div>
</div>
<div class="set">
<div class="label">Password</div>
<div class="field"><input type = "password"></div>
</div>
<div class="linkset">
<div class="link"><a href="signup">Don't have an account?</a></div>
<div class="submitbutton">
<input type = "Submit" value = "GO!" class = "submit">
</div>
</div>
</form>
</div>
</div>
</body>
</html>
......@@ -29,7 +29,7 @@
<td class="tabno">'.$i.'</td>
<td class="tabloc">
<div id="locationtext'.$i.'">'.$row["location"].'</div>
<input class="locationinput" id="locationinput'.$i.'" type="text">
<input class="locationinput" id="locationinput'.$i.'" type="hidden">
</td>
<td class="tabact">
<div class="addset" align="center">
......
<?php
include "../model/user.php";
if($_SERVER["REQUEST_METHOD"] == "POST") {
$user = new User;
$result = $user->getUserByLogIn($_POST['username'], $_POST['password']);
$count = mysqli_num_rows($result);
$result = $result->fetch_assoc();
if($count == 1) {
if ($result['isDriver']) {
header("location:dashboard.php?id=" . $result["id"]);
} else {
header("location:dashboard.php?id=" . $result["id"]);
}
} else {
echo "<script>alert('Username dan/atau password yang anda masukkan salah.')</script>";
}
}
?>
<html>
<head>
<title>Projekers - Login</title>
......@@ -13,15 +31,15 @@
</div>
<div class = "form_input">
<form>
<form method="POST">
<div class="set">
<div class="label">Username</div>
<div class="field"><input type = "text"></div>
<div class="field"><input type="text" name="username"></div>
</div>
<div class="set">
<div class="label">Password</div>
<div class="field"><input type = "password"></div>
<div class="field"><input type="password" name="password"></div>
</div>
<div class="linkset">
......
......@@ -59,7 +59,7 @@
<br>
<div class="bottom">
<div class="redirect-login">
<a href="login.html">Already have an account?</a>
<a href="index.php">Already have an account?</a>
</div>
<div class="register">
<input type="submit" value="REGISTER" name="register">
......
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