-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_info.php
45 lines (29 loc) · 928 Bytes
/
update_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
<?php
session_start();
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "signup";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
echo json_encode(['success' => false, 'error' => 'Database connection failed']);
exit();
}
if (!isset($_SESSION['email'])) {
echo json_encode(['success' => false, 'error' => 'User not logged in']);
exit();
}
$email = $_SESSION['email'];
$name = $_POST['name'];
$number = $_POST['number'];
$stmt = $conn->prepare("UPDATE registration SET name = ?, number = ? WHERE email = ?");
$stmt->bind_param("sss", $name, $number, $email);
$stmt->execute();
if ($stmt->affected_rows > 0) {
echo json_encode(['success' => true]);
} else {
echo json_encode(['success' => false, 'error' => 'Failed to update information']);
}
$stmt->close();
$conn->close();
?>