From eda57f305a1efc772993894c16f2b61d60140922 Mon Sep 17 00:00:00 2001 From: Iqbal <iqbalkhowarizmi@ymail.com> Date: Sat, 7 Oct 2017 20:36:28 +0700 Subject: [PATCH] Configured routing with index.php. --- public/order.js | 8 ++++---- public/profil_edit.js | 4 ++-- src/controller/LoginController.php | 5 ++++- src/view/order.php | 6 +++--- src/view/profil.php | 10 +++++----- src/view/profil_edit.php | 4 ++-- src/view/profil_edit_location.php | 8 ++++---- 7 files changed, 24 insertions(+), 21 deletions(-) diff --git a/public/order.js b/public/order.js index 4f0b517..955b590 100755 --- a/public/order.js +++ b/public/order.js @@ -14,7 +14,7 @@ function makeOrder() { var data = "id="+customerID+"&pickup="+orderPickup+"&destination="+orderDestination+"&driver="+orderPreferredDriver; if (orderPickup.trim() == "" || orderDestination.trim() == "") { - alert("Sorce and destination is required!"); + alert("Source and destination is required!"); return; } @@ -31,7 +31,7 @@ function makeOrder() { } }; - xhttp.open("POST", "/main/order/new", true); + xhttp.open("POST", "/index.php/main/order/new", true); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.send(data); } @@ -144,11 +144,11 @@ function completeOrder(id) { alert("Fail completing your order"); } else { alert("Thanks for your order :D"); - window.location.href = "/main/order?u="+customerID; + window.location.href = "/index.php/main/order?u="+customerID; } } }; - xhttp.open("POST", "/main/order/finish?u", true); + xhttp.open("POST", "/index.php/main/order/finish?u", true); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.send(data); diff --git a/public/profil_edit.js b/public/profil_edit.js index 66c774a..f9af165 100644 --- a/public/profil_edit.js +++ b/public/profil_edit.js @@ -83,13 +83,13 @@ function saveLocation(location, newlocation) { xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { if (this.responseText == "Success") { - window.location.href = "/main/profil/location/edit?u="+id; + window.location.href = "/index.php/main/profil/location/edit?u="+id; } else { alert(this.responseText); } } }; - xhttp.open("POST", "/main/profil/location/edit/data", true); + xhttp.open("POST", "/index.php/main/profil/location/edit/data", true); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.send(data); } \ No newline at end of file diff --git a/src/controller/LoginController.php b/src/controller/LoginController.php index 00a3cb1..6f65475 100644 --- a/src/controller/LoginController.php +++ b/src/controller/LoginController.php @@ -32,7 +32,10 @@ class LoginController if ($userData !== null && $userData instanceof User) { if ($userData->password === $password) { $_SESSION['username'] = $username; - echo "<script type='application/javascript'> alert('Login berhasil'); </script>"; + + $userPage = simpleCrypt($userData->id); + header("Location: /index.php/main/profil?u=$userPage"); + //echo "<script type='application/javascript'> alert('Login berhasil'); </script>"; } else { echo "<script type='application/javascript'> alert('Password salah.'); </script>"; } diff --git a/src/view/order.php b/src/view/order.php index 2a0760e..62c1c0c 100644 --- a/src/view/order.php +++ b/src/view/order.php @@ -15,9 +15,9 @@ </div> </div> <div class="row"> - <a class="col-2 tab text-center active" href="/main/order?u=<?=$id?>">ORDER</a> - <a class="col-2 tab text-center" href="/main/hostory?u=<?=$id?>">HISTORY</a> - <a class="col-2 tab text-center" href="/main/profil?u=<?=$id?>">MY PROFILE</a> + <a class="col-2 tab text-center active" href="/index.php/main/order?u=<?=$id?>">ORDER</a> + <a class="col-2 tab text-center" href="/index.php/main/history?u=<?=$id?>">HISTORY</a> + <a class="col-2 tab text-center" href="/index.php/main/profil?u=<?=$id?>">MY PROFILE</a> </div> <div class="row"> <div class="col-6"><h1>MAKE AN ORDER</h1></div> diff --git a/src/view/profil.php b/src/view/profil.php index 7e12042..a060cf2 100644 --- a/src/view/profil.php +++ b/src/view/profil.php @@ -15,13 +15,13 @@ </div> </div> <div class="row"> - <a class="col-2 tab text-center" href="/main/order?u=<?=$id?>">ORDER</a> - <a class="col-2 tab text-center" href="/main/hostory?u=<?=$id?>">HISTORY</a> - <a class="col-2 tab text-center active" href="/main/profil?u=<?=$id?>">MY PROFILE</a> + <a class="col-2 tab text-center" href="/index.php/main/order?u=<?=$id?>">ORDER</a> + <a class="col-2 tab text-center" href="/index.php/main/hostory?u=<?=$id?>">HISTORY</a> + <a class="col-2 tab text-center active" href="/index.php/main/profil?u=<?=$id?>">MY PROFILE</a> </div> <div class="row"> <div class="col-5"><h1>MY PROFILE</h1></div> - <div class="col-1 text-right"><a class="edit" href="/main/profil/edit?u=<?=$id?>"></a></div> + <div class="col-1 text-right"><a class="edit" href="/index.php/main/profil/edit?u=<?=$id?>"></a></div> </div> <div class="text-center profil"> <img class="img-circle" src="<?=$user->photo?>"/><br> @@ -38,7 +38,7 @@ <?php if ($user->isDriver) : ?> <div class="row"> <div class="col-5"><h2>PREFERED LOCATIONS</h2></div> - <div class="col-1 text-right"><a class="edit" href="/main/profil/location/edit?u=<?=$id?>"></a></div> + <div class="col-1 text-right"><a class="edit" href="/index.php/main/profil/location/edit?u=<?=$id?>"></a></div> </div> <div class="row"> <?php if ($location_count == 0): ?> diff --git a/src/view/profil_edit.php b/src/view/profil_edit.php index 12da5e7..a8e48a2 100644 --- a/src/view/profil_edit.php +++ b/src/view/profil_edit.php @@ -15,7 +15,7 @@ </div> </div> <div class="row"> - <form action="/main/profil/edit/save?u=<?=$id?>" method="post" enctype="multipart/form-data" onsubmit="return validateProfileEdit()"> + <form action="/index.php/main/profil/edit/save?u=<?=$id?>" method="post" enctype="multipart/form-data" onsubmit="return validateProfileEdit()"> <div class="container" style="width: 65%"> <div class="row"> <div class="col-6 text-left"> @@ -73,7 +73,7 @@ <br> <div class="row"> <div class="col-3 text-left"> - <a class="btn red" href="/main/profil?u=<?=$id?>">BACK</a> + <a class="btn red" href="/index.php/main/profil?u=<?=$id?>">BACK</a> </div> <div class="col-3 text-right"> <input class="btn green" type="submit" value="SAVE"> diff --git a/src/view/profil_edit_location.php b/src/view/profil_edit_location.php index 9a21605..4a1710d 100644 --- a/src/view/profil_edit_location.php +++ b/src/view/profil_edit_location.php @@ -42,7 +42,7 @@ <input id="input-location-<?=$no-1?>" class="input-location" type="text" style="width: 100%; line-height: 24px; padding-left:3px; font-size: medium; display: none;"></td> <td style="text-align: center"> <a id="action-edit-<?=$no-1?>" class="action-edit" onclick="editLocation(<?=$no-1?>)" data="<?=$no-1?>"></a> - <a class="action-delete" href="/main/profil/location/delete?u=<?=$id?>&name=<?=$data['location']?>" onclick="return confirm('Are you sure want to delete?')"></a> + <a class="action-delete" href="/index.php/main/profil/location/delete?u=<?=$id?>&name=<?=$data['location']?>" onclick="return confirm('Are you sure want to delete?')"></a> </td> </tr> <?php endforeach;?> @@ -61,7 +61,7 @@ <div class="row"> <div class="col-1"></div> <div class="col-4"> - <form action="/main/profil/location/add?u=<?=$id?>" method="post" onsubmit="return validateLocationEdit()"> + <form action="/index.php/main/profil/location/add?u=<?=$id?>" method="post" onsubmit="return validateLocationEdit()"> <input id="locationInput" type="text" name="location" style="width:76%;height: 30px; font-size: medium"> <input class="btn green" type="submit" value="ADD" style="width:20%;margin-left: 10px"> </form> @@ -72,13 +72,13 @@ <div class="row"> <div class="col-1"></div> <div class="col-4"> - <a class="btn red" href="/main/profil?u=<?=$id?>">BACK</a> + <a class="btn red" href="/index.php/main/profil?u=<?=$id?>">BACK</a> </div> <div class="col-1"></div> </div> </div> </div> </div> -<script type="text/javascript" src="/profil_edit.js"></script> +<script type="text/javascript" src="/index.php/profil_edit.js"></script> </body> </html> \ No newline at end of file -- GitLab