diff --git a/css/profile.css b/css/profile.css index 497b442ee445c17724db962ac0d432f8e2c4d342..6a9f6e1f6e04400b8080d93855678546c6b5ab34 100755 --- a/css/profile.css +++ b/css/profile.css @@ -6,22 +6,30 @@ text-align: left; margin-top: 0; } -.profile_subtitle { - height: 10%; +.profile_container { + height: 70%; +} +.profile_header { + height: 15%; } .profile_title { float: left; } .profile_title h1 { text-align: left; - margin: 0 ; + margin: 0; } .edit_profile_button { float: right; margin-top: 0; margin-right: 10 px; } -.image_frame { +.myprofile { + text-align: center; + margin-left: auto; + margin-right: auto; +} +.profilepict_frame { width: 100px; height: 100px; overflow: auto; @@ -29,21 +37,18 @@ margin-left: auto; margin-right: auto; } -.image_frame img { +.profilepict_frame img { display: inline; margin: 0 auto; height: 100%; width: 100%; } -.myprofile { - text-align: center; - margin-left: auto; - margin-right: auto; +.profile_info { + height: 100px; } #edit_profile_page { height: 550px; width: 400px; - overflow-y: scroll; } #edit_profile_page h1 { text-align: left; diff --git a/login/login.php b/login/login.php index 2321c7a5051639fd45c0ca65298206ad21a3efc4..14b3e2820774d51abaddc33948724917174f1583 100755 --- a/login/login.php +++ b/login/login.php @@ -15,10 +15,9 @@ $dbpassword=$row['password']; $user_id=$row['user_id']; } - //echo $user_id; if($username == $dbusername && $password == $dbpassword) { - header("Location: ../profile_page/profile.php?id=$user_id%26&username=$username"); + header("Location: ../profile_page/profile.php?id=$user_id"); } } else { include("login.html"); diff --git a/login/sign_up.php b/login/sign_up.php index bce711dba2e288488ed36ddebfcf3392cf3f6fb9..4ffcec2cf634a649b07ccd7ec992cb581a71862b 100644 --- a/login/sign_up.php +++ b/login/sign_up.php @@ -28,11 +28,12 @@ { $getUserID = mysqli_query($con,"SELECT user_id FROM user WHERE username='".$username."'") or die(mysql_error()); $row=mysqli_fetch_assoc($getUserID); - $user_id=$row['id']; + $user_id=$row['user_id']; + header("Location: ../profile_page/profile.php?id=?$user_id"); if ($status == "customer") { - header("Location: ../order/order.php?id=?$user_id&username=$username"); + header("Location: ../order/order.php?id=?$user_id"); } else { - header("Location: ../profile_page/profile.php?id=?$user_id%26&username=$username"); + header("Location: ../order/order.php?id=?$user_id"); } } mysqli_close($con); diff --git a/profile_page/edit_profile.php b/profile_page/edit_profile.php index 6df332def3127325978a2ddc717106d1bbb7bd32..69e1236ee8c5f34267064065de42a7d428675c30 100755 --- a/profile_page/edit_profile.php +++ b/profile_page/edit_profile.php @@ -9,7 +9,20 @@ <body> <div class="frame" id="edit_profile_page"> <div class="header"> - <?php include '../template/header.php';?> + <?php + $user_id = $_GET['id']; + include '../database/dbconnect.php'; + + $query=mysqli_query($con,"SELECT * FROM user WHERE user_id='".$user_id."'") or die(mysqli_error()); + + if(mysqli_num_rows($query)!=0) + { + $row=mysqli_fetch_assoc($query); + $username = $row['username']; + include("../template/header.php"); + } + mysqli_close($con); + ?> </div> <div class="menu"> <?php include '../template/menu.php';?> @@ -58,6 +71,7 @@ </div> </div> <div> + <input id="hidden_userid" name="hidden_userid" type="text" style="display:none;"> <button class="button" style="float: left;"><a href="profile.php">BACK</a></button> <input type="submit" value="SAVE" style="float: right;" class="button"> </div> @@ -65,25 +79,12 @@ </div> </div> <?php - include '../database/dbconnect.php'; - - $username = $_GET['username']; - $user_id = $_GET['id']; - $query=mysqli_query($con,"SELECT * FROM user WHERE username='".$username."'") or die(mysqli_error()); - - $numrows=mysqli_num_rows($query); - if($numrows!=0) - { - while($row=mysqli_fetch_assoc($query)) - { - echo "<script>document.getElementById('current_name').value = '".$row['name']."'</script>"; - echo "<script>document.getElementById('current_phone').value = '".$row['phone']."'</script>"; - if (isset($row['pict'])) { - echo "<script>document.getElementById('edit_profile_pict').src ='getProfilePict.php?username=".$username."'</script>"; - } - } + echo "<script>document.getElementById('current_name').value = '".$row['name']."'</script>"; + echo "<script>document.getElementById('current_phone').value = '".$row['phone']."'</script>"; + if (isset($row['pict'])) { + echo "<script>document.getElementById('edit_profile_pict').src ='getProfilePict.php?id=".$user_id."'</script>"; } - mysqli_close($con); + echo "<script>document.getElementById('hidden_userid').value =".$user_id."</script>"; ?> <script> function showFileName(inputFile) { diff --git a/profile_page/getProfilePict.php b/profile_page/getProfilePict.php index c4c1c6c848912d2a139461a01b1fa8c03e2a550a..1a448af3e58a7421981a65768857f246f6a52145 100644 --- a/profile_page/getProfilePict.php +++ b/profile_page/getProfilePict.php @@ -1,7 +1,7 @@ <?php - $user = $_GET['username']; + $user_id = $_GET['id']; include '../database/dbconnect.php'; - $query=mysqli_query($con,"SELECT pict FROM user WHERE username='".$user."'") or die(mysqli_error()); + $query=mysqli_query($con,"SELECT pict FROM user WHERE user_id='".$user_id."'") or die(mysqli_error()); $row=mysqli_fetch_assoc($query); mysqli_close($con); if (isset($row['pict'])) { diff --git a/profile_page/profile.php b/profile_page/profile.php index 689591bfb3464d014ecd54f792a431bb67b97c63..f9e04fa7ccd48f19a0e04e7c4e1b4a81322a583a 100755 --- a/profile_page/profile.php +++ b/profile_page/profile.php @@ -1,6 +1,5 @@ <?php - $username = $_GET['username']; - $user_id = $_GET['id']; + ?> <html> <head> @@ -12,29 +11,35 @@ <body> <div class="frame" id="profile_frame"> <div class="header"> - <?php include'../template/header.php';?> + <?php + $user_id = $_GET['id']; + include '../database/dbconnect.php'; + + $query=mysqli_query($con,"SELECT * FROM user WHERE user_id='".$user_id."'") or die(mysqli_error()); + + if(mysqli_num_rows($query)!=0) + { + $row=mysqli_fetch_assoc($query); + $username = $row['username']; + include("../template/header.php"); + } + mysqli_close($con); + ?> </div> <div class="menu"> <?php include'../template/menu.php';?> </div> - <div class="profile_subtitle"> - <div class="profile_title"><h1>My Profile</h1></div> - <div class="edit_profile_button"><a href=<?php echo 'edit_profile.php?id='.$user_id.'%26&username='.$username; ?>>✎</a></div> - </div> - <div class="myprofile"> - <div class="image_frame"> - <img id="profile_pict" src="../img/default_profile.jpeg"> + <div class="profile_container"> + <div class="profile_header"> + <div class="profile_title"><h1>My Profile</h1></div> + <div class="edit_profile_button"><a href=<?php echo 'edit_profile.php?id='.$user_id; ?>>✎</a></div> </div> - <?php - include '../database/dbconnect.php'; - - $query=mysqli_query($con,"SELECT * FROM user WHERE username='".$username."'") or die(mysqli_error()); - - $numrows=mysqli_num_rows($query); - if($numrows!=0) - { - while($row=mysqli_fetch_assoc($query)) - { + <div class="myprofile"> + <div class="profilepict_frame"> + <img id="profile_pict" src="../img/default_profile.jpeg"> + </div> + <div class="profile_info"> + <?php echo "</br><strong>".$row['username']."</strong></br>"; echo $row['name']."</br>"; if ($row['status'] == "driver") { @@ -43,12 +48,11 @@ echo $row['email']."</br>"; echo $row['phone']."</br>"; if (isset($row['pict'])) { - echo "<script>document.getElementById('profile_pict').src ='getProfilePict.php?username=".$username."'</script>"; + echo "<script>document.getElementById('profile_pict').src ='getProfilePict.php?id=".$user_id."'</script>"; } - } - } - mysqli_close($con); - ?> + ?> + </div> + </div> </div> </div> </body> diff --git a/profile_page/update_profile.php b/profile_page/update_profile.php index 400d991a6e5216bad200e41d5a7811635ed70f5d..950595932c49fb977eaeec52a998c766eeb5a526 100644 --- a/profile_page/update_profile.php +++ b/profile_page/update_profile.php @@ -2,8 +2,8 @@ session_start(); if ($_SERVER["REQUEST_METHOD"] == "POST") { include '../database/dbconnect.php'; - if (isset($_FILES) && ($_FILES['profile_pictfile']['size'] > 0) && !empty($_POST['edit_name']) && !empty($_POST['edit_phone'])) { - $username = $_SESSION['user']; + if (isset($_FILES) && ($_FILES['profile_pictfile']['size'] > 0) && !empty($_POST['edit_name']) && !empty($_POST['edit_phone']) && !empty($_POST['hidden_userid'])) { + $user_id = $_POST['hidden_userid']; $new_name = $_POST['edit_name']; $new_phone = $_POST['edit_phone']; if(isset($_POST['is_driver'])) @@ -42,11 +42,11 @@ { $fileName = addslashes($fileName); } - $query=mysqli_query($con,"UPDATE user set name='".$new_name."',phone='".$new_phone."',status='".$status."',pict='".$content."'WHERE username='".$username."'") or die(mysqli_error()); + $query=mysqli_query($con,"UPDATE user set name='".$new_name."',phone='".$new_phone."',status='".$status."',pict='".$content."'WHERE user_id='".$user_id."'") or die(mysqli_error()); } if($query) { - header("Location: profile.php?id=$user_id%26&username=$username"); + header("Location: profile.php?id=$user_id"); } mysqli_close($con); } diff --git a/template/header.php b/template/header.php index 048cb2fd654f7240aacaf7a6ce7069c6979e5338..7dc0dbded32246764f57c861a6f4d77bdfc9326a 100644 --- a/template/header.php +++ b/template/header.php @@ -4,7 +4,7 @@ <p>"An ojek for anything you need"</p></br> </div> <div class="greeting"> - <p>Hello, '.'"'.$_GET['username'].'"'.'</p> - <p><a href="../login/logout.php">Logout</a></p> + <p>Hello,'.'"'.$username.'!"</p> + <p><a href="../login/logout.php">Logout </a></p> </div>'; ?>