-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_user.php
More file actions
47 lines (38 loc) · 1.49 KB
/
Copy pathupdate_user.php
File metadata and controls
47 lines (38 loc) · 1.49 KB
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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "charity_db";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve data from the form
$user_id = $_POST['user_id'];
$phone = $_POST['phone'];
$address = $_POST['address'];
$website = $_POST['website'];
$focus_areas = $_POST['focus_areas'];
$geographical_scope = $_POST['geographical_scope'];
$collaboration_interests = $_POST['collaboration_interests'];
$key_achievements = $_POST['key_achievements'];
$partnerships = $_POST['partnerships'];
// Prepare update statement
$stmt = $conn->prepare("UPDATE users SET phone=?, address=?, website=?, focus_areas=?, geographical_scope=?, collaboration_interests=?, key_achievements=?, partnerships=? WHERE id=?");
$stmt->bind_param("ssssssssi", $phone, $address, $website, $focus_areas, $geographical_scope, $collaboration_interests, $key_achievements, $partnerships, $user_id);
// Execute the update statement
if ($stmt->execute() === TRUE) {
echo "User information updated successfully";
} else {
echo "Error updating user information: " . $conn->error;
}
// Close statement
$stmt->close();
}
// Close connection
$conn->close();
?>