-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit.php
More file actions
29 lines (25 loc) · 867 Bytes
/
Copy pathedit.php
File metadata and controls
29 lines (25 loc) · 867 Bytes
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
<?php
require 'auth.php';
$id = $_GET['id'] ?? null;
$contact = R::load('contact', $id);
if (!$contact->id || $contact->user_id !== $_SESSION['user_id']) {
exit("Unauthorized");
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$contact->name = $_POST['name'];
$contact->email = $_POST['email'];
$contact->phone = $_POST['phone'];
R::store($contact);
header("Location: index.php");
exit;
}
?>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<h2>Edit Contact</h2>
<form method="post">
<input name="name" value="<?= htmlspecialchars($contact->name) ?>" required><br>
<input name="email" value="<?= htmlspecialchars($contact->email) ?>" required><br>
<input name="phone" value="<?= htmlspecialchars($contact->phone) ?>" required><br>
<button>Update</button>
<a href="index.php">Cancel</a>
</form>