[e3d4e0a] | 1 | <?php
|
---|
| 2 | session_start();
|
---|
| 3 | if(!isset($_SESSION['user_ID'])) {
|
---|
| 4 | header("Location: ./Log In.php");
|
---|
| 5 | }
|
---|
| 6 |
|
---|
| 7 | require './connect.php';
|
---|
| 8 |
|
---|
| 9 | if($_SERVER['REQUEST_METHOD'] === 'POST') {
|
---|
| 10 |
|
---|
| 11 | $res = mysqli_query($conn, "SELECT users_information.*, users.username, users.email FROM users_information INNER JOIN users ON users_information.user_id = users.user_ID WHERE
|
---|
| 12 | users.user_id = {$_SESSION['user_ID']};
|
---|
| 13 | ");
|
---|
| 14 |
|
---|
| 15 | if(mysqli_num_rows($res) == 0) {
|
---|
| 16 | mysqli_query($conn, "INSERT INTO users_information(user_id, name, surname, phone_number, city, address, postal_code) VALUES (
|
---|
| 17 | {$_SESSION['user_ID']}, '{$_POST['name']}', '{$_POST['surname']}', '{$_POST['phone_number']}', '{$_POST['city']}', '{$_POST['address']}', '{$_POST['postal_code']}');
|
---|
| 18 | ");
|
---|
| 19 | }
|
---|
| 20 | else {
|
---|
| 21 | mysqli_query($conn, "UPDATE users_information SET name = '{$_POST['name']}', surname = '{$_POST['surname']}', phone_number = '{$_POST['phone_number']}',
|
---|
| 22 | city = '{$_POST['city']}', address = '{$_POST['address']}', postal_code = '{$_POST['postal_code']}' WHERE user_id = {$_SESSION['user_ID']};
|
---|
| 23 | ");
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | header('location: ./Profile.php');
|
---|
| 27 | die();
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | $res = mysqli_query($conn, "SELECT users_information.*, users.username, users.email FROM users_information INNER JOIN users ON users_information.user_id = users.user_ID WHERE
|
---|
| 31 | users.user_id = {$_SESSION['user_ID']};
|
---|
| 32 | ");
|
---|
| 33 |
|
---|
| 34 | $user_data = $res->fetch_assoc();
|
---|
| 35 | ?>
|
---|
| 36 | <!DOCTYPE html>
|
---|
| 37 | <html lang="en">
|
---|
| 38 | <head>
|
---|
| 39 | <meta charset="UTF-8">
|
---|
| 40 | <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
---|
| 41 | <link rel="stylesheet" href="./CSS/EditProfile.css">
|
---|
| 42 | <title>Edit Profile</title>
|
---|
| 43 | </head>
|
---|
| 44 | <body>
|
---|
| 45 | <form action="./EditProfile.php" method="POST">
|
---|
| 46 | <div class="form-section">
|
---|
| 47 | <div class="form-card">
|
---|
| 48 | <label for="name">Име:</label>
|
---|
| 49 | <input type="text" name="name" required value="<?php
|
---|
| 50 | if(mysqli_num_rows($res) != 0) {
|
---|
| 51 | echo $user_data['name'];
|
---|
| 52 | }
|
---|
| 53 | ?>">
|
---|
| 54 | </div>
|
---|
| 55 | <div class="form-card">
|
---|
| 56 | <label for="surname">Презиме:</label>
|
---|
| 57 | <input type="text" name="surname" required value="<?php
|
---|
| 58 | if(mysqli_num_rows($res) != 0) {
|
---|
| 59 | echo $user_data['surname'];
|
---|
| 60 | }
|
---|
| 61 | ?>">
|
---|
| 62 | </div>
|
---|
| 63 | </div>
|
---|
| 64 | <div class="form-section">
|
---|
| 65 | <div class="form-card">
|
---|
| 66 | <label for="phone-number">Тел. Број:</label>
|
---|
| 67 | <input type="tel" name="phone_number" required value="<?php
|
---|
| 68 | if(mysqli_num_rows($res) != 0) {
|
---|
| 69 | echo $user_data['phone_number'];
|
---|
| 70 | }
|
---|
| 71 | ?>">
|
---|
| 72 | </div>
|
---|
| 73 | <div class="form-card">
|
---|
| 74 | <label for="city">City:</label>
|
---|
| 75 | <input type="text" name="city" required value="<?php
|
---|
| 76 | if(mysqli_num_rows($res) != 0) {
|
---|
| 77 | echo $user_data['city'];
|
---|
| 78 | }
|
---|
| 79 | ?>">
|
---|
| 80 | </div>
|
---|
| 81 | </div>
|
---|
| 82 | <div class="form-section">
|
---|
| 83 | <div class="form-card">
|
---|
| 84 | <label for="address">Address:</label>
|
---|
| 85 | <input type="text" name="address" required value="<?php
|
---|
| 86 | if(mysqli_num_rows($res) != 0) {
|
---|
| 87 | echo $user_data['address'];
|
---|
| 88 | }
|
---|
| 89 | ?>">
|
---|
| 90 | </div>
|
---|
| 91 | <div class="form-card">
|
---|
| 92 | <label for="postal-code">Postal Code:</label>
|
---|
| 93 | <input type="text" name="postal_code" required value="<?php
|
---|
| 94 | if(mysqli_num_rows($res) != 0) {
|
---|
| 95 | echo $user_data['postal_code'];
|
---|
| 96 | }
|
---|
| 97 | ?>">
|
---|
| 98 | </div>
|
---|
| 99 | </div>
|
---|
| 100 | <div class="form-section" style="display: flex; justify-content: center;">
|
---|
| 101 | <a href="Profile.php">Back</a>
|
---|
| 102 | <input type="submit" value="Save">
|
---|
| 103 | </div>
|
---|
| 104 | </form>
|
---|
| 105 | </body>
|
---|
| 106 | </html> |
---|