commit jun 24

This commit is contained in:
2024-06-24 09:42:54 +02:00
parent 6e1ecbc485
commit d0f1607632
9 changed files with 383 additions and 208 deletions

View File

@@ -116,19 +116,36 @@
</ul> </ul>
</div> </div>
<img src="assets/images/logo.webp" class="logo-img mt-3 mt-lg-0 mt-md-0" alt=""> <img src="assets/images/logo.webp" class="logo-img mt-3 mt-lg-0 mt-md-0" alt="">
<div class="dropdown" id="dropdownid" style="position: absolute; width:fit-content;"> <!-- Login -->
<div class="dropdown" id="dropdownid" style="position: absolute; width: fit-content;">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false"> <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-users"></i> <i class="fa-solid fa-users"></i>
</a> </a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink"> <ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<?php if (loggedin()) { <?php
if (loggedin()) {
echo '<li><a class="dropdown-item" href="php/logout.php">Log out</a></li>'; echo '<li><a class="dropdown-item" href="php/logout.php">Log out</a></li>';
if (is_admin()) {
echo '<li><a class="dropdown-item" href="admin_panel.php">Admin panel</a></li>';
}
} else { } else {
echo '<li><a class="dropdown-item" href="login.html">Log in</a></li> echo '<li><a class="dropdown-item" href="login.html">Log in</a></li>
<li><a class="dropdown-item" href="signup.php">Sign up</a></li>'; <li><a class="dropdown-item" href="signup.php">Sign up</a></li>';
} ?> }
?>
</ul> </ul>
</div> </div>
<!-- Weather icon -->
<?php if (loggedin()) {
echo '<div class="weather-div" style="position: absolute; color: white; font-size: 25px; left:12%; top:15px;">
<a style="color:white" href="weather.php"><i class="fa-solid fa-cloud-sun"></i></a>
<div>';
} ?>
<!-- site navigation--> <!-- site navigation-->
@@ -579,7 +596,9 @@
// Get the button // Get the button
let mybutton = document.getElementById("scrollToTopBtn"); let mybutton = document.getElementById("scrollToTopBtn");
window.onscroll = function() {scrollFunction()}; window.onscroll = function() {
scrollFunction()
};
function scrollFunction() { function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {

View File

@@ -11,7 +11,7 @@ if (mysqli_select_db($con, $mysql_db)) {
mysqli_query($con, $delete_query); mysqli_query($con, $delete_query);
} }
$query = "SELECT `name`, `surname`, `email`, `birth_day`, `birth_month`, `birth_year` FROM `globaly_accounts`"; $query = "SELECT `name`, `surname`, `email`, `birth_day`, `birth_month`, `birth_year`, `city` FROM `globaly_accounts`";
$query_run = mysqli_query($con, $query); $query_run = mysqli_query($con, $query);
if (mysqli_num_rows($query_run) > 0) { if (mysqli_num_rows($query_run) > 0) {
@@ -21,6 +21,7 @@ if (mysqli_select_db($con, $mysql_db)) {
<th>Surname</th> <th>Surname</th>
<th>Email</th> <th>Email</th>
<th>Birth Date</th> <th>Birth Date</th>
<th>City</th>
<th>Edit</th> <th>Edit</th>
</tr>'; </tr>';
@@ -29,18 +30,20 @@ if (mysqli_select_db($con, $mysql_db)) {
$surname = $query_row['surname']; $surname = $query_row['surname'];
$email = $query_row['email']; $email = $query_row['email'];
$birth_date = $query_row['birth_day'] . '.' . $query_row['birth_month'] . '.' . $query_row['birth_year'] . '.'; $birth_date = $query_row['birth_day'] . '.' . $query_row['birth_month'] . '.' . $query_row['birth_year'] . '.';
$city = $query_row['city'];
echo '<tr> echo '<tr>
<td>' . htmlspecialchars($name) . '</td> <td>' . htmlspecialchars($name) . '</td>
<td>' . htmlspecialchars($surname) . '</td> <td>' . htmlspecialchars($surname) . '</td>
<td>' . htmlspecialchars($email) . '</td> <td>' . htmlspecialchars($email) . '</td>
<td>' . htmlspecialchars($birth_date) . '</td> <td>' . htmlspecialchars($birth_date) . '</td>
<td>' . htmlspecialchars($city) . '</td>
<td id="edit-td"> <td id="edit-td">
<form id="delete-form" method="POST" action=""> <form id="delete-form" method="POST" action="">
<input type="hidden" name="delete_email" value="' . htmlspecialchars($email) . '"> <input type="hidden" name="delete_email" value="' . htmlspecialchars($email) . '">
<button id="delete-btn" type="submit"><i class="fa-regular fa-circle-xmark"></i></button> <button id="delete-btn" type="submit"><i class="fa-regular fa-circle-xmark"></i></button>
</form> </form>
<a id="edit-user" href="edit-user.php"><i class="fa-solid fa-user-pen"></i></a> <a id="edit-user" href="edit-user.php?name=' . urlencode($name) . '&surname=' . urlencode($surname) . '&email=' . urlencode($email) . '&birth_day=' . urlencode($query_row['birth_day']) . '&birth_month=' . urlencode($query_row['birth_month']) . '&birth_year=' . urlencode($query_row['birth_year']) . '&city=' . urlencode($query_row['city']) . '"><i class="fa-solid fa-user-pen"></i></a>
</td> </td>
</tr>'; </tr>';
} }

View File

@@ -94,20 +94,36 @@
</ul> </ul>
</div> </div>
<img src="assets/images/logo.webp" class="logo-img mt-3 mt-lg-0 mt-md-0" alt=""> <img src="assets/images/logo.webp" class="logo-img mt-3 mt-lg-0 mt-md-0" alt="">
<div class="dropdown" id="dropdownid" style="position: absolute; width:fit-content;"> <!-- Login -->
<div class="dropdown" id="dropdownid" style="position: absolute; width: fit-content;">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false"> <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-users"></i> <i class="fa-solid fa-users"></i>
</a> </a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink"> <ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<?php if (loggedin()) { <?php
if (loggedin()) {
echo '<li><a class="dropdown-item" href="php/logout.php">Log out</a></li>'; echo '<li><a class="dropdown-item" href="php/logout.php">Log out</a></li>';
if (is_admin()) {
echo '<li><a class="dropdown-item" href="admin_panel.php">Admin panel</a></li>';
}
} else { } else {
echo '<li><a class="dropdown-item" href="login.html">Log in</a></li> echo '<li><a class="dropdown-item" href="login.html">Log in</a></li>
<li><a class="dropdown-item" href="signup.php">Sign up</a></li>'; <li><a class="dropdown-item" href="signup.php">Sign up</a></li>';
} ?> }
?>
</ul> </ul>
</div> </div>
<!-- Weather icon -->
<?php if (loggedin()) {
echo '<div class="weather-div" style="position: absolute; color: white; font-size: 25px; left:12%; top:15px;">
<a style="color:white" href="weather.php"><i class="fa-solid fa-cloud-sun"></i></a>
<div>';
} ?>
<!-- site navigation--> <!-- site navigation-->
@@ -355,7 +371,9 @@
// Get the button // Get the button
let mybutton = document.getElementById("scrollToTopBtn"); let mybutton = document.getElementById("scrollToTopBtn");
window.onscroll = function() {scrollFunction()}; window.onscroll = function() {
scrollFunction()
};
function scrollFunction() { function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {

View File

@@ -94,20 +94,36 @@
</ul> </ul>
</div> </div>
<img src="assets/images/logo.webp" class="logo-img mt-3 mt-lg-0 mt-md-0" alt=""> <img src="assets/images/logo.webp" class="logo-img mt-3 mt-lg-0 mt-md-0" alt="">
<div class="dropdown" id="dropdownid" style="position: absolute; width:fit-content;"> <!-- Login -->
<div class="dropdown" id="dropdownid" style="position: absolute; width: fit-content;">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false"> <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-users"></i> <i class="fa-solid fa-users"></i>
</a> </a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink"> <ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<?php if (loggedin()) { <?php
if (loggedin()) {
echo '<li><a class="dropdown-item" href="php/logout.php">Log out</a></li>'; echo '<li><a class="dropdown-item" href="php/logout.php">Log out</a></li>';
if (is_admin()) {
echo '<li><a class="dropdown-item" href="admin_panel.php">Admin panel</a></li>';
}
} else { } else {
echo '<li><a class="dropdown-item" href="login.html">Log in</a></li> echo '<li><a class="dropdown-item" href="login.html">Log in</a></li>
<li><a class="dropdown-item" href="signup.php">Sign up</a></li>'; <li><a class="dropdown-item" href="signup.php">Sign up</a></li>';
} ?> }
?>
</ul> </ul>
</div> </div>
<!-- Weather icon -->
<?php if (loggedin()) {
echo '<div class="weather-div" style="position: absolute; color: white; font-size: 25px; left:12%; top:15px;">
<a style="color:white" href="weather.php"><i class="fa-solid fa-cloud-sun"></i></a>
<div>';
} ?>
<!-- site navigation--> <!-- site navigation-->
@@ -254,7 +270,9 @@
// Get the button // Get the button
let mybutton = document.getElementById("scrollToTopBtn"); let mybutton = document.getElementById("scrollToTopBtn");
window.onscroll = function() {scrollFunction()}; window.onscroll = function() {
scrollFunction()
};
function scrollFunction() { function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {

View File

@@ -116,42 +116,60 @@
</style> </style>
</head> </head>
<?php
require 'php/connect.inc.php';
$name = htmlspecialchars($_GET['name']);
$surname = htmlspecialchars($_GET['surname']);
$email = htmlspecialchars($_GET['email']);
$birth_day = htmlspecialchars($_GET['birth_day']);
$birth_month = htmlspecialchars($_GET['birth_month']);
$birth_year = htmlspecialchars($_GET['birth_year']);
$city = htmlspecialchars($_GET['city']);
?>
<body> <body>
<div class="form d-flex flex-column align-items-center justify-content-center my-md-5 mb-5 mb-lg-0"> <div class="form d-flex flex-column align-items-center justify-content-center my-md-5 mb-5 mb-lg-0">
<div class="headline-card d-flex flex-column align-items-center justify-content-center mt-4"> <div class="headline-card d-flex flex-column align-items-center justify-content-center mt-4">
<h2>Edit user</h2> <h2>Edit user</h2>
<img class="line-img" src="assets/images/line.png" alt=""> <img class="line-img" src="assets/images/line.png" alt="">
</div> </div>
<form action="php/add_user_register.php" method="post"> <form action="php/update-user.php" method="post">
<div class="form-container-bot d-flex flex-column align-items-start justify-content-center"> <div class="form-container-bot d-flex flex-column align-items-start justify-content-center">
<input class="input-text" type="text" placeholder="User's Name" name="name"> <input class="input-text" type="text" name="name" value="<?php echo $name; ?>">
<input class="input-text" type="text" placeholder="User's Surname" name="surname"> <input class="input-text" type="text" name="surname" value="<?php echo $surname; ?>">
<input class="input-text" type="text" placeholder="User's Email" name="email"> <input class="input-text" type="text" name="email" value="<?php echo $email; ?>">
<input class="input-text" type="password" id="password" placeholder="Password" name="password"> <input class="input-text" type="password" id="password" placeholder="Password" name="password">
<i id="togglePassword" class="fa-solid fa-eye"></i> <i id="togglePassword" class="fa-solid fa-eye"></i>
<p id="generate-password">generete</p> <p id="generate-password">generate</p>
<input class="input-text" type="password" id="confirm-password" placeholder="Confirm Password" name="password_again"> <input class="input-text" type="password" id="confirm-password" placeholder="Confirm Password" name="password_again">
<input class="input-text" type="text" placeholder="User's City" name="city"> <input class="input-text" type="text" name="city" value="<?php echo $city; ?>">
<h6>Date of birth:</h6> <h6>Date of birth:</h6>
<div class="date-container"> <div class="date-container">
<span> <span>
<select name="birth_day"> <select name="birth_day">
<?php <?php
$start_date = 1; $start_date = 1;
$end_date = 31; $end_date = 31;
for ($j = $start_date; $j <= $end_date; $j++) { for ($j = $start_date; $j <= $end_date; $j++) {
echo '<option value=' . $j . '>' . $j . '</option>'; $selected = ($j == $birth_day) ? 'selected' : '';
echo '<option value="' . $j . '" ' . $selected . '>' . $j . '</option>';
} }
?> ?>
</select> </select>
</span> </span>
<span> <span>
<select name="birth_month"> <select name="birth_month">
<?php for ($m = 1; $m <= 12; ++$m) { <?php
for ($m = 1; $m <= 12; ++$m) {
$month_label = date('F', mktime(0, 0, 0, $m, 1)); $month_label = date('F', mktime(0, 0, 0, $m, 1));
$selected = ($month_label == $birth_month) ? 'selected' : '';
echo '<option value="' . $month_label . '" ' . $selected . '>' . $month_label . '</option>';
}
?> ?>
<option value="<?php echo $month_label; ?>"><?php echo $month_label; ?></option>
<?php } ?>
</select> </select>
</span> </span>
<span> <span>
@@ -161,7 +179,8 @@
$min = $year - 100; $min = $year - 100;
$max = $year; $max = $year;
for ($i = $max; $i >= $min; $i--) { for ($i = $max; $i >= $min; $i--) {
echo '<option value=' . $i . '>' . $i . '</option>'; $selected = ($i == $birth_year) ? 'selected' : '';
echo '<option value="' . $i . '" ' . $selected . '>' . $i . '</option>';
} }
?> ?>
</select> </select>
@@ -172,7 +191,7 @@
<input type="hidden" id="exampleCheckboxValue" name="admin" value="0"> <input type="hidden" id="exampleCheckboxValue" name="admin" value="0">
</div> </div>
</div> </div>
<input class="view-more" type="submit" value="Add user"> <input class="view-more" type="submit" value="Edit user">
</div> </div>
</form> </form>

View File

@@ -95,20 +95,36 @@
</ul> </ul>
</div> </div>
<img src="assets/images/logo.webp" class="logo-img mt-3 mt-lg-0 mt-md-0" alt=""> <img src="assets/images/logo.webp" class="logo-img mt-3 mt-lg-0 mt-md-0" alt="">
<div class="dropdown" id="dropdownid" style="position: absolute; width:fit-content;"> <!-- Login -->
<div class="dropdown" id="dropdownid" style="position: absolute; width: fit-content;">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false"> <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-users"></i> <i class="fa-solid fa-users"></i>
</a> </a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink"> <ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<?php if (loggedin()) { <?php
if (loggedin()) {
echo '<li><a class="dropdown-item" href="php/logout.php">Log out</a></li>'; echo '<li><a class="dropdown-item" href="php/logout.php">Log out</a></li>';
if (is_admin()) {
echo '<li><a class="dropdown-item" href="admin_panel.php">Admin panel</a></li>';
}
} else { } else {
echo '<li><a class="dropdown-item" href="login.html">Log in</a></li> echo '<li><a class="dropdown-item" href="login.html">Log in</a></li>
<li><a class="dropdown-item" href="signup.php">Sign up</a></li>'; <li><a class="dropdown-item" href="signup.php">Sign up</a></li>';
} ?> }
?>
</ul> </ul>
</div> </div>
<!-- Weather icon -->
<?php if (loggedin()) {
echo '<div class="weather-div" style="position: absolute; color: white; font-size: 25px; left:12%; top:15px;">
<a style="color:white" href="weather.php"><i class="fa-solid fa-cloud-sun"></i></a>
<div>';
} ?>
<!-- site navigation--> <!-- site navigation-->
@@ -584,7 +600,9 @@
// Get the button // Get the button
let mybutton = document.getElementById("scrollToTopBtn"); let mybutton = document.getElementById("scrollToTopBtn");
window.onscroll = function() {scrollFunction()}; window.onscroll = function() {
scrollFunction()
};
function scrollFunction() { function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {

View File

@@ -225,20 +225,36 @@
</ul> </ul>
</div> </div>
<img src="assets/images/logo.webp" class="logo-img mt-3 mt-lg-0 mt-md-0" alt=""> <img src="assets/images/logo.webp" class="logo-img mt-3 mt-lg-0 mt-md-0" alt="">
<div class="dropdown" id="dropdownid" style="position: absolute; width:fit-content;"> <!-- Login -->
<div class="dropdown" id="dropdownid" style="position: absolute; width: fit-content;">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false"> <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-users"></i> <i class="fa-solid fa-users"></i>
</a> </a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink"> <ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<?php if (loggedin()) { <?php
if (loggedin()) {
echo '<li><a class="dropdown-item" href="php/logout.php">Log out</a></li>'; echo '<li><a class="dropdown-item" href="php/logout.php">Log out</a></li>';
if (is_admin()) {
echo '<li><a class="dropdown-item" href="admin_panel.php">Admin panel</a></li>';
}
} else { } else {
echo '<li><a class="dropdown-item" href="login.html">Log in</a></li> echo '<li><a class="dropdown-item" href="login.html">Log in</a></li>
<li><a class="dropdown-item" href="signup.php">Sign up</a></li>'; <li><a class="dropdown-item" href="signup.php">Sign up</a></li>';
} ?> }
?>
</ul> </ul>
</div> </div>
<!-- Weather icon -->
<?php if (loggedin()) {
echo '<div class="weather-div" style="position: absolute; color: white; font-size: 25px; left:12%; top:15px;">
<a style="color:white" href="weather.php"><i class="fa-solid fa-cloud-sun"></i></a>
<div>';
} ?>
<!-- site navigation--> <!-- site navigation-->
@@ -368,8 +384,8 @@
<div class="card4 d-flex align-items-center justify-content-center flex-column mb-4"> <div class="card4 d-flex align-items-center justify-content-center flex-column mb-4">
<img class="img-fourth-au" src="assets/images/team3.jpg" alt=""> <img class="img-fourth-au" src="assets/images/team3.jpg" alt="">
<div class="card-text4 d-flex align-items-center justify-content-start flex-column"> <div class="card-text4 d-flex align-items-center justify-content-start flex-column">
<h4 class="h4-fourth"><?php echo $data[3]['name'] . ' ' . $data[3]['surname']; ?></h4> <h4 class="h4-fourth"><?php echo $data[11]['name'] . ' ' . $data[11]['surname']; ?></h4>
<p class="p-fourth"><?php echo $data[3]['email'] . '<br>' . $data[3]['birth_day'] . '.' . $data[3]['birth_month'] . '.' . $data[3]['birth_year'] . '.'; ?></p> <p class="p-fourth"><?php echo $data[11]['email'] . '<br>' . $data[11]['birth_day'] . '.' . $data[11]['birth_month'] . '.' . $data[11]['birth_year'] . '.'; ?></p>
</div> </div>
</div> </div>
</div> </div>
@@ -395,8 +411,8 @@
<div class="card4 d-flex align-items-center justify-content-center flex-column mb-4"> <div class="card4 d-flex align-items-center justify-content-center flex-column mb-4">
<img class="img-fourth-au" src="assets/images/team6.jpg" alt=""> <img class="img-fourth-au" src="assets/images/team6.jpg" alt="">
<div class="card-text4 d-flex align-items-center justify-content-start flex-column"> <div class="card-text4 d-flex align-items-center justify-content-start flex-column">
<h4 class="h4-fourth"><?php echo $data[6]['name'] . ' ' . $data[6]['surname']; ?></h4> <h4 class="h4-fourth"><?php echo $data[15]['name'] . ' ' . $data[15]['surname']; ?></h4>
<p class="p-fourth"><?php echo $data[6]['email'] . '<br>' . $data[6]['birth_day'] . '.' . $data[6]['birth_month'] . '.' . $data[6]['birth_year'] . '.'; ?></p> <p class="p-fourth"><?php echo $data[15]['email'] . '<br>' . $data[15]['birth_day'] . '.' . $data[15]['birth_month'] . '.' . $data[15]['birth_year'] . '.'; ?></p>
</div> </div>
</div> </div>
</div> </div>
@@ -417,10 +433,11 @@
</thead> </thead>
<tbody> <tbody>
<?php <?php
for ($id = 7; $id <= max(array_keys($data)); $id++) { $maxId = max(array_keys($data));
for ($id = 7; $id <= $maxId; $id++) {
if (isset($data[$id])) { if (isset($data[$id])) {
echo "<tr>"; echo "<tr>";
// Combine key and value for birth date into a formatted string
$birthDate = "{$data[$id]['birth_day']}.{$data[$id]['birth_month']}.{$data[$id]['birth_year']}."; $birthDate = "{$data[$id]['birth_day']}.{$data[$id]['birth_month']}.{$data[$id]['birth_year']}.";
echo "<td class='td-others'>{$data[$id]['name']}</td>"; echo "<td class='td-others'>{$data[$id]['name']}</td>";
@@ -428,13 +445,12 @@
echo "<td class='td-others'>{$data[$id]['email']}</td>"; echo "<td class='td-others'>{$data[$id]['email']}</td>";
echo "<td class='td-others'>$birthDate</td>"; echo "<td class='td-others'>$birthDate</td>";
echo "</tr>"; echo "</tr>";
} else {
echo "<tr><td colspan='4'>No data found for ID $id</td></tr>";
} }
} }
?> ?>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>

46
php/update-user.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
require 'connect.inc.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Retrieve data from the form
$name = mysqli_real_escape_string($con, $_POST['name']);
$surname = mysqli_real_escape_string($con, $_POST['surname']);
$email = mysqli_real_escape_string($con, $_POST['email']);
$password = mysqli_real_escape_string($con, $_POST['password']);
$password_again = mysqli_real_escape_string($con, $_POST['password_again']);
$city = mysqli_real_escape_string($con, $_POST['city']);
$birth_day = mysqli_real_escape_string($con, $_POST['birth_day']);
$birth_month = mysqli_real_escape_string($con, $_POST['birth_month']);
$birth_year = mysqli_real_escape_string($con, $_POST['birth_year']);
$admin = mysqli_real_escape_string($con, $_POST['admin']);
// Hash the password if it was provided
if (!empty($password) && $password == $password_again) {
$password_hashed = md5($password);
$password_update = "password = '$password_hashed',";
} else {
$password_update = "";
}
$query = "UPDATE `globaly_accounts` SET
name = '$name',
surname = '$surname',
email = '$email',
$password_update
city = '$city',
birth_day = '$birth_day',
birth_month = '$birth_month',
birth_year = '$birth_year',
admin = '$admin'
WHERE email = '$email'";
if (mysqli_query($con, $query)) {
echo '<script type="text/javascript">
alert("You have successfully edit the user!");
window.location.href = "../admin_panel.php";
</script>';
} else {
echo "Error updating user information: " . mysqli_error($con);
}
}
?>

View File

@@ -95,20 +95,36 @@
</ul> </ul>
</div> </div>
<img src="assets/images/logo.webp" class="logo-img mt-3 mt-lg-0 mt-md-0" alt=""> <img src="assets/images/logo.webp" class="logo-img mt-3 mt-lg-0 mt-md-0" alt="">
<div class="dropdown" id="dropdownid" style="position: absolute; width:fit-content;"> <!-- Login -->
<div class="dropdown" id="dropdownid" style="position: absolute; width: fit-content;">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false"> <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-users"></i> <i class="fa-solid fa-users"></i>
</a> </a>
<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink"> <ul class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<?php if (loggedin()) { <?php
if (loggedin()) {
echo '<li><a class="dropdown-item" href="php/logout.php">Log out</a></li>'; echo '<li><a class="dropdown-item" href="php/logout.php">Log out</a></li>';
if (is_admin()) {
echo '<li><a class="dropdown-item" href="admin_panel.php">Admin panel</a></li>';
}
} else { } else {
echo '<li><a class="dropdown-item" href="login.html">Log in</a></li> echo '<li><a class="dropdown-item" href="login.html">Log in</a></li>
<li><a class="dropdown-item" href="signup.php">Sign up</a></li>'; <li><a class="dropdown-item" href="signup.php">Sign up</a></li>';
} ?> }
?>
</ul> </ul>
</div> </div>
<!-- Weather icon -->
<?php if (loggedin()) {
echo '<div class="weather-div" style="position: absolute; color: white; font-size: 25px; left:12%; top:15px;">
<a style="color:white" href="weather.php"><i class="fa-solid fa-cloud-sun"></i></a>
<div>';
} ?>
<!-- site navigation--> <!-- site navigation-->
@@ -405,7 +421,9 @@
// Get the button // Get the button
let mybutton = document.getElementById("scrollToTopBtn"); let mybutton = document.getElementById("scrollToTopBtn");
window.onscroll = function() {scrollFunction()}; window.onscroll = function() {
scrollFunction()
};
function scrollFunction() { function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {