Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
<?php
$DBservername = "localhost";
$DBusername = "root";
$DBpassword = "";
$conn = new mysqli($DBservername, $DBusername, $DBpassword, "pr-ojek");
if ($conn->connect_error) {
echo "Server is die";
die("Connection failed: " . $conn->connect_error);
}
?>
\ No newline at end of file
function editLocation(elmt){
var row = elmt.parentElement.parentElement.parentElement;
var textBefore = row.children[1].children[0].value;
row.children[1].children[0].disabled = false;
row.children[2].children[0].children[0].innerHTML = "done";
row.children[2].children[0].children[0].style.color = "#02702C";
row.children[2].children[1].children[0].innerHTML = "clear";
row.children[2].children[1].children[0].style.color = "red";
row.children[2].children[0].children[0].onclick = function(){ saveLocation(elmt, textBefore)};
row.children[2].children[1].children[0].onclick = function(){ cancelLocation(elmt, textBefore)};
}
function saveLocation(elmt, textBefore){
var row = elmt.parentElement.parentElement.parentElement;
row.children[1].children[0].disabled = true;
row.children[2].children[0].children[0].innerHTML = "mode_edit";
row.children[2].children[0].children[0].style.color = "orange";
row.children[2].children[1].children[0].innerHTML = "delete";
row.children[2].children[1].children[0].style.color = "red";
row.children[2].children[0].children[0].onclick = function(){ editLocation(elmt)};
row.children[2].children[1].children[0].onclick = function(){ deleteLocation(elmt)};
var text = encodeURI(row.children[1].children[0].value);
textBefore = encodeURI(textBefore);
var xmlhttp = new XMLHttpRequest();
if(!xmlhttp){
return;
}
var url = "editlocationhandler.php?id_active="+ id + "&update=" + text + "&location=" + textBefore;
xmlhttp.open("GET", url, true);
xmlhttp.send();
location.reload();
}
function cancelLocation(elmt, text){
var row = elmt.parentElement.parentElement.parentElement;
row.children[1].children[0].value = text;
row.children[1].children[0].disabled = true;
row.children[2].children[0].children[0].innerHTML = "mode_edit";
row.children[2].children[0].children[0].style.color = "orange";
row.children[2].children[1].children[0].innerHTML = "delete";
row.children[2].children[1].children[0].style.color = "red";
row.children[2].children[0].children[0].onclick = function(){ editLocation(elmt)};
row.children[2].children[1].children[0].onclick = function(){ deleteLocation(elmt)};
}
function deleteLocation(elmt){
if (confirm("Are you sure deleting the location ?") == true) {
var row = elmt.parentElement.parentElement.parentElement;
var text = encodeURI(row.children[1].children[0].value);
var xmlhttp = new XMLHttpRequest();
if(!xmlhttp){
return;
}
var url = "editlocationhandler.php?id_active="+ id + "&delete=" + text;
xmlhttp.open("GET", url, true);
xmlhttp.send();
location.reload();
}
}
\ No newline at end of file
function removeElement(id) {
document.getElementById(id).style.display = "none";
}
\ No newline at end of file
function validasi(){
var pick = document.forms['menuAwal']['pickingPoint'].value;
var destiny = document.forms['menuAwal']['destination'].value;
return pick !== "" && destiny !== "";
}
var clicked1 = false;
function next1(){
var benar = true;
var x = document.getElementById("menuAwal");
var i;
for (i = 0; i < x.length-2 && benar; ++i){
benar = (x.elements[i].value !== "");
}
if (benar){
var pick = x.elements[0].value;
var destiny = x.elements[1].value;
var prefer_driver = x.elements[x.length-2].value;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "order.php?pick="+pick+"&destiny="+destiny+"&prefer_driver="+prefer_driver);
xmlhttp.send();
document.getElementById('box_aktif').innerHTML =
'<div class="stepBox">' +
'<div class="number">1</div>' +
'<div class="step">Select Destination</div>' +
'</div>' +
'<div class="stepBox active">' +
'<span class="number">2</span>' +
'<div class="step">Select a Driver</div>' +
'</div>' +
'<div class="stepBox">' +
'<span class="number">3</span>' +
'<div class="step">Complete your order</div>' +
'</div>' +
'<div class="roundedBox preferred">' +
'<div class="header3"><b>PREFERRED DRIVERS:</b></div>' +
'<br><br>' +
'<div class="header3 paragraph">' +
(prefer_driver === "" ? "NOTHING TO DISPLAY :(" : prefer_driver) +
'</div>' +
'</div>' +
'<div class="roundedBox others">'+
'<span class="header3"><b>OTHER DRIVERS:</b></span>' +
'</div>' +
'<input type="submit" name="next2" value="NEXT" onclick="next2()">';
}
}
function next2(){
document.getElementById('box_aktif').innerHTML =
'<div class="stepBox">' +
'<div class="number">1</div>' +
'<div class="step">Select Destination</div>' +
'</div>' +
'<div class="stepBox active">' +
'<span class="number">2</span>' +
'<div class="step">Select a Driver</div>' +
'</div>' +
'<div class="stepBox">' +
'<span class="number">3</span>' +
'<div class="step">Complete your order</div>' +
'</div>' +
'<form class>'+
'<div class="star">'+
'<span class="star-rating star-5">'+
'<input type="radio" name="rating" value="1"><i></i>'+
'<input type="radio" name="rating" value="2"><i></i>'+
'<input type="radio" name="rating" value="3"><i></i>'+
'<input type="radio" name="rating" value="4"><i></i>'+
'<input type="radio" name="rating" value="5"><i></i>'+
'</span>'+
'</div>'+
'<input class="commentBox" type="text" name="comment" placeholder="Your comment...">'
'<input type="submit" name="submit" value="COMPLETE ORDER">'
'</form>';
}
\ No newline at end of file
document.getElementById("uploadBtn").onchange = function () {
document.getElementById("uploadFile").value = this.value;
};
\ No newline at end of file
function getUsernameValidation(){
var xmlhttp = new XMLHttpRequest();
if(!xmlhttp){
return;
}
var username = document.getElementById("username");
console.log(username);
var url = "validation.php?u=" + username.value;
console.log(url);
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
var response = xmlhttp.responseText;
console.log(response);
if(response === "true"){
document.getElementById("wrongUsername").style.display = "none";
document.getElementById("checkUsername").style.display = "block";
}
else {
document.getElementById("checkUsername").style.display = "none";
document.getElementById("wrongUsername").style.display = "block";
}
}
}
xmlhttp.send();
}
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function getEmailValidation(){
var email = document.getElementById("email");
console.log(email.value);
console.log(validateEmail(email.value));
if (!validateEmail(email.value)){
document.getElementById("checkEmail").style.display = "none";
document.getElementById("wrongEmail").style.display = "block";
}
else {
var xmlhttp = new XMLHttpRequest();
if(!xmlhttp){
return;
}
console.log(email);
var url = "validation.php?e=" + email.value;
console.log(url);
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
var response = xmlhttp.responseText;
console.log(response);
if(response === "true"){
document.getElementById("wrongEmail").style.display = "none";
document.getElementById("checkEmail").style.display = "block";
}
else {
document.getElementById("checkEmail").style.display = "none";
document.getElementById("wrongEmail").style.display = "block";
}
}
}
xmlhttp.send();
}
}
\ No newline at end of file
<?php
require_once('includes/config.php');
if(isset($_POST["submit"])){
$username = $_POST["username"];
$password = $_POST["password"];
$sql = "SELECT ID, username, password FROM users WHERE username = '$username' limit 1";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_assoc($result)) {
$ID = $row["ID"];
$passwordconf = $row["password"];
}
if($password !== $passwordconf){
echo "<script>alert('Wrong password!')</script>";
}
else {
$_SESSION["id_active"] = $row["ID"];
header('Location: profile.php?id_active=' . $ID);
exit;
}
}
else {
echo "<script>alert('User not exist!')</script>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Halaman Login</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
<link rel="stylesheet" href="css/auth.css">
</head>
<body>
<div class="apps">
<div class="form-heading">
<div class="heading-left">
<hr>
</div>
<div class="heading-title">
LOGIN
</div>
<div class="heading-right">
<hr>
</div>
</div>
<div class="form-login">
<form action="" method="POST" autocomplete="off">
<div class="form-group">
<label for="username">Username </label>
<input id="username" type="text" name="username" placeholder="your username" required>
</div>
<div class="form-group">
<label for="password">Password </label>
<input id="password" type="password" name="password" placeholder="your password" pattern=".{5,10}" title="5 to 10 characters" required>
</div>
<div class="action">
<div class="register">
<a href="signup.php">Don't have an account ?</a>
</div>
<div class="submit">
<input type="submit" name="submit" value="GO!">
</div>
</div>
</form>
</div>
</div>
</body>
</html>
<?php
require('includes/config.php');
if(isset($_POST["submit"])) {
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Make an order</title>
<link rel="stylesheet" type="text/css" href="css/orderojek.css">
<script src="js/order.js"></script>
</head>
<body>
<div class="contentBox">
<div class="mainHeader">
<div class="header1">
<div class="title"><span class="title green">PR</span>-<span class=" title red">OJEK</span></div>
<div class="subtitle">wush... wush... ngeeeeeenggg...</div>
</div>
<div class="header2">
<div class="username">Hi, <span class="username bold">pikachu!</span></div>
<div class="logout"><a href="login.php">Logout</a></div>
</div>
</div>
<div>
<div class="menu active">ORDER</div>
<div class="menu">HISTORY</div>
<div class="menu">MY PROFILE</div>
</div>
<h1>MAKE AN ORDER</h1>
<div id="box_aktif">
<div class="stepBox active">
<div class="number">1</div>
<div class="step">Select Destination</div>
</div>
<div class="stepBox">
<span class="number">2</span>
<div class="step">Select a Driver</div>
</div>
<div class="stepBox">
<span class="number">3</span>
<div class="step">Complete your order</div>
</div>
<form action="selectdriver.php" id="menuAwal" name="menuAwal" method="POST" class="form" onsubmit="validasi()">
<div class="formBox">
<label for="pick" class="labelBox">Picking Point</label>
<input id="pick" class="inputBox" type="text" name="pickingPoint" id="pickingPoint" required>
</div>
<div class="formBox">
<label for="destiny" class="labelBox">Destination</label>
<input id="destiny" class="inputBox" type="text" name="destination" id="destination" required>
</div>
<div class="formBox">
<label for="preferred" class="labelBox">Preferred Driver</label>
<input id="preferred" class="inputBox" type="text" name="preferredDriver" placeholder="(optional)">
</div>
<div class="next">
<input type="submit" name="next" value="NEXT">
</div>
</form>
</div>
</div>
</body>
</html>
\ No newline at end of file
<?php
require('includes/config.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>Make an order</title>
<link rel="stylesheet" type="text/css" href="css/orderojek.css">
<script src="js/order.js"></script>
</head>
<body>
<div class="contentBox">
<div class="mainHeader">
<div class="header1">
<div class="title"><span class="title green">PR</span>-<span class=" title red">OJEK</span></div>
<div class="subtitle">wush... wush... ngeeeeeenggg...</div>
</div>
<div class="header2">
<div class="username">Hi, <span class="username bold">pikachu!</span></div>
<div class="logout">Logout</div>
</div>
</div>
<div>
<div class="menu active">ORDER</div>
<div class="menu">HISTORY</div>
<div class="menu">MY PROFILE</div>
</div>
<h1>MAKE AN ORDER</h1>
<div id="box_aktif">
<div class="stepBox">
<div class="number">1</div>
<div class="step">Select Destination</div>
</div>
<div class="stepBox active">
<span class="number">2</span>
<div class="step">Select a Driver</div>
</div>
<div class="stepBox">
<span class="number">3</span>
<div class="step">Complete your order</div>
</div>
<div class="roundedBox preferred">
<span class="header3"><b>PREFERRED DRIVERS:</b></span>
<br><br>
<div class="header3 paragraph">
<?php
$con = mysqli_connect('127.0.0.1','root','','pr-ojek');
$prefer_driver = $_POST['preferredDriver'];
$query = "SELECT * FROM drivers NATURAL JOIN users WHERE name like '%".$prefer_driver."%' ORDER BY total_rating/total_passangers LIMIT 1";
$tmp = mysqli_query($con, $query);
$exist = $prefer_driver !== "" && mysqli_num_rows($tmp) == 1;
$res = mysqli_fetch_assoc($tmp);
if ($exist){
$image = '<img src="' . $res['image'] . '" class="gambar">';
echo $image.'<div class="header3 lain">' . $res['name'] . '</div>';
echo '<div class="header3 lain2"> ☆'.$res['total_rating']/($res['total_passangers'] > 0 ? $res['total_passangers'] : 1) . ' (' . $res['total_passangers'] . ' votes) </div><br>';
echo '<form action="completeorder.php" id="menuDua" name="menuDua" method="POST">';
echo '<div class="choosen">';
echo '<input type="submit" name="choosen" value="I CHOOSE YOU!">';
echo '<input type="hidden" name="ID" value="' . $res['ID'] . '">';
echo '<input type="hidden" name="pickingPoint" value="' . $_POST['pickingPoint'] . '">';
echo '<input type="hidden" name="destination" value="' . $_POST['destination'] . '">';
echo '</div>';
echo '</form>';
} else {
echo "NOTHING TO DISPLAY :(";
}
?>
</div>
</div>
<div class="roundedBox others">
<div class="header3"><b>OTHER DRIVERS:</b></div>
<?php
$con = mysqli_connect('127.0.0.1','root','','pr-ojek');
$query = "SELECT * FROM drivers NATURAL JOIN users NATURAL JOIN driver_locations WHERE name NOT like '%".$prefer_driver."%' AND location = '" . $_POST['pickingPoint'] . "' ORDER BY total_rating/total_passangers";
$tmp = mysqli_query($con, $query);
$exist = $prefer_driver !== "" && mysqli_num_rows($tmp) > 0;
if ($exist){
while ($res = mysqli_fetch_assoc($tmp)){
$image = '<img src="' . $res['image'] . '" class="gambar">';
echo $image.'<div class="header3 lain">' . $res['name'] . '</div>';
echo '<div class="header3 lain2"> ☆'.$res['total_rating']/($res['total_passangers'] > 0 ? $res['total_passangers'] : 1) . ' (' . $res['total_passangers'] . ' votes) </div><br>';
echo '<form action="completeorder.php" id="menuDua" name="menuDua" method="POST">';
echo '<div class="choosen">';
echo '<input type="submit" name="choosen" value="I CHOOSE YOU!">';
echo '<input type="hidden" name="ID" value="' . $res['ID'] . '">';
echo '<input type="hidden" name="pickingPoint" value="' . $_POST['pickingPoint'] . '">';
echo '<input type="hidden" name="destination" value="' . $_POST['destination'] . '">';
echo '</div>';
echo '</form>';
echo '<br><br><br>';
}
} else {
echo "NOTHING TO DISPLAY :(";
}
?>
</div>
</div>
</body>
</html>
\ No newline at end of file
<?php
require('includes/config.php');
if(isset($_POST["submit"])){
if($_POST["password"] !== $_POST["password_conf"]){
echo "<script>alert('Your password is not match!')</script>";
}
else {
$name = $_POST["name"];
$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["password"];
$phone_number = $_POST["phone"];
$driver = (!isset($_POST["driver"])) ? 0 : 1;
$sql = "INSERT INTO users (name, username, email, password, phone_number, driver)
VALUES ('$name', '$username', '$email', '$password', '$phone_number', $driver)";
if ($conn->query($sql) === TRUE) {
$sql = "SELECT ID FROM users WHERE username = '$username' LIMIT 1";
$result = mysqli_query($conn, $sql);
while($row = mysqli_fetch_assoc($result)) {
$ID = $row["ID"];
}
if ($driver === 1){
$sql = "INSERT INTO drivers (ID, name)
VALUES ($ID,'$name')";
if($conn->query($sql) === TRUE){
echo "New driver record created successfully<br>";
}
}
header('Location: profile.php?id_active=' . $ID);
exit;
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Halaman Signup</title>
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="css/auth.css">
</head>
<body>
<div class="apps">
<div class="form-heading">
<div class="heading-left">
<hr>
</div>
<div class="heading-title">
SIGNUP
</div>
<div class="heading-right">
<hr>
</div>
</div>
<div class="form-signup">
<form action="" method="POST" autocomplete="off">
<div class="form-group">
<label for="name">Your Name</label>
<input id="name" type="text" name="name" placeholder="your name" required>
</div>
<div class="form-group">
<label for="username">Username</label>
<input id="username" type="text" name="username" placeholder="your username" onfocusout="getUsernameValidation()" required> <span><i class="material-icons" id="checkUsername">check</i><i class="material-icons" id="wrongUsername">info</i></span>
</div>
<div class="form-group">
<label for="email">Email</label>
<input id="email" type="text" name="email" placeholder="your email" onfocusout="getEmailValidation()" required><span><i class="material-icons" id="checkEmail">check</i><i class="material-icons" id="wrongEmail">info</i></span>
</div>
<div class="form-group">
<label for="password">Password</label>
<input id="password" type="password" name="password" placeholder="your password" pattern=".{5,10}" title="5 to 10 characters" required>
</div>
<div class="form-group">
<label for="password_conf">Password Confirm</label>
<input id="password_conf" type="password" name="password_conf" placeholder="your password again" pattern=".{5,10}" title="5 to 10 characters" required>
</div>
<div class="form-group">
<label for="phone">Phone Number</label>
<input id="phone" type="text" name="phone" placeholder="your phone" required>
</div>
<input type="checkbox" name="driver" value="true"> Also sign me up as a driver!
<div class="action">
<div class="login">
<a href="login.php">Already have an account ?</a>
</div>
<div class="submit">
<input type="submit" name="submit" value="REGISTER">
</div>
</div>
</form>
</div>
</div>
<script src="js/validation.js"></script>
</body>
</html>
<?php
?>
\ No newline at end of file
<?php
if (!empty($_REQUEST['u'])){
$usernames = array("adyanf", "adyanaufalF", "adyanaufalfikri");
$toCheck = $_REQUEST['u'];
if (in_array($toCheck, $usernames)){
echo "false";
}
else {
echo "true";
}
}
if (!empty($_REQUEST['e'])){
$emails = array("adyanaufalf@gmail.com", "adyanaufalfikri@gmail.com", "13515130@std.stei.itb.ac.id");
$toCheck = $_REQUEST['e'];
if (in_array($toCheck, $emails)){
echo "false";
}
else {
echo "true";
}
}
?>
\ No newline at end of file