diff --git a/css/profile.css b/css/profile.css index 1ed0e0f156b1056686cd2d19a52825e3eef421f2..94dbd5cff904004445f89624a545f7fb4bd0bf6b 100644 --- a/css/profile.css +++ b/css/profile.css @@ -22,8 +22,8 @@ body { } .profile-img { - width: 40%; width: 150px; + height: 170px; display: inline-block; } @@ -34,7 +34,8 @@ body { .thumbnail { border: 1px solid black; - max-width: 100%; + max-width: 150px; + max-height: 170px; height: auto; } diff --git a/editpreferredlocations.php b/editpreferredlocations.php index 6b8caaede349853e67b03d202159522de0b82a00..0678be99748741a25fd19dd0d0b74752a3eac762 100644 --- a/editpreferredlocations.php +++ b/editpreferredlocations.php @@ -1,3 +1,35 @@ +<?php +require('includes/config.php'); + +$id_active = $_GET["id_active"]; +$sql = "SELECT name, phone_number, driver, image FROM users WHERE ID=$id_active LIMIT 1"; + +$result = mysqli_query($conn, $sql); +while($row = mysqli_fetch_assoc($result)) { + $name = $row["name"]; + $phone_number = $row["phone_number"]; + $driver = $row["driver"]; + $image = $row["image"]; +} + +if(isset($_POST["back"])){ + header('Location: profile.php?id_active=' . $id_active); +} + +if(isset($_POST["submit"])) { + $name = $_POST["name"]; + $phone_number = $_POST["phone"]; + $driver = (!isset($_POST["driver"])) ? 0 : 1; + + $sql = "UPDATE users SET name='$name', phone_number='$phone_number', driver=$driver, image='$image' WHERE ID=$id_active"; + if ($conn->query($sql) === TRUE) { + //echo "Record updated successfully"; + } else { + //echo "Error updating record: " . $conn->error; + } +} +?> + <!DOCTYPE html> <html> <head> @@ -23,17 +55,17 @@ <tr> <td>1</td> <td><input type="text" value="Pewter City" disabled></td> - <td><span class="edit"><i class="material-icons">mode_edit</i></span><span class="delete"><i class="material-icons">clear</i></span></td> + <td><span class="edit"><i class="material-icons" onclick="editLocation(this)">mode_edit</i></span><span class="delete"><i class="material-icons" onclick="deleteLocation(this)">clear</i></span></td> </tr> <tr> <td>2</td> <td><input type="text" value="Saffron City" disabled></td> - <td><span class="edit"><i class="material-icons">mode_edit</i></span><span class="delete"><i class="material-icons">clear</i></span></td> + <td><span class="edit"><i class="material-icons" onclick="editLocation(this)">mode_edit</i></span><span class="delete"><i class="material-icons" onclick="deleteLocation(this)">clear</i></span></td> </tr> <tr> <td>3</td> <td><input type="text" value="SkyPillar City" disabled></td> - <td><span class="edit"><i class="material-icons">mode_edit</i></span><span class="delete"><i class="material-icons">clear</i></span></td> + <td><span class="edit"><i class="material-icons" onclick="editLocation(this)">mode_edit</i></span><span class="delete" onclick="deleteLocation(this)"><i class="material-icons">clear</i></span></td> </tr> </tbody> </table> @@ -45,9 +77,9 @@ </form> </div> <div class="back"> - <a href="#">BACK</a> + <a href="<?php echo 'profile.php?id_active=' . $id_active ?>">BACK</a> </div> </div> - <script src="js/profile.js"></script> + <script src="js/editlocation.js"></script> </body> </html> diff --git a/js/editlocation.js b/js/editlocation.js new file mode 100644 index 0000000000000000000000000000000000000000..c3e9d5c3e6e1fcf5ecbffb7af23c617797c24ebb --- /dev/null +++ b/js/editlocation.js @@ -0,0 +1,60 @@ +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[0].children[0].onclick = function(){ saveLocation(elmt, textBefore)}; + row.children[2].children[1].children[0].onclick = function(){ cancelLocation(elmt, textBefore)}; +} + +function saveLocation(elmt, text){ + 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[0].children[0].onclick = function(){ editLocation(elmt)}; + row.children[2].children[1].children[0].onclick = function(){ deleteLocation(elmt)}; +} + +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[0].children[0].onclick = function(){ editLocation(elmt)}; + row.children[2].children[1].children[0].onclick = function(){ deleteLocation(elmt)}; +} + +function deleteLocation(elmt){ + var row = elmt.parentElement.parentElement.parentElement; + row.children[1].children[0].disabled = true; +} + +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(); +} \ No newline at end of file