-
Notifications
You must be signed in to change notification settings - Fork 0
/
change-info.php
68 lines (59 loc) · 2.31 KB
/
change-info.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="styles/main.css">
<link rel="stylesheet" href="styles/contact.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
<script src="script.js"></script>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
<title>Zmena adresy a úprava kontaktných údajov</title>
<body onload = time();>
<?php require_once "./header.php" ?>
<?php require_once 'libs/users.php' ?>
<?php
require_once 'libs/db.php';
if($_SESSION['usertype'] != "admin"){
header("location: index.php");
}
if (isset($_POST['update'])) {
$id = $_POST['id'];
$address = $_POST['address'];
$mayor = $_POST['mayor'];
$phone = $_POST['phone'];
$email = $_POST['email'];
mysqli_query($db, "UPDATE contact SET address='$address', mayor='$mayor', phone='$phone', email='$email' WHERE id=$id");
header('location: contact.php');
}
?>
<?php
if (isset($_GET['edit'])) {
$id = $_GET['edit'];
$update = true;
$record = mysqli_query($db, "SELECT * FROM contact WHERE id=$id");
$n = mysqli_fetch_array($record);
$address = $n['address'];
$mayor = $n['mayor'];
$phone = $n['phone'];
$email = $n['email'];
}
?>
<div class="content">
<form method="post" action="change-info.php">
<label>Adresa</label>
<input type="text" name="address" value="<?= $address ?>" required>
<label>Starosta</label>
<input type="text" name="mayor" value="<?= $mayor ?>" required>
<label>Telefón</label>
<input type="text" name="phone" value="<?= $phone ?>" required>
<label>Email</label>
<input type="text" name="email" value="<?= $email ?>" required>
<button class="submit" name="update">Upraviť údaje</button>
<input type="hidden" name="id" value="<?php echo $id; ?>">
</form>
</div>
<?php require_once "./footer.php" ?>
</body>
</html>