-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdateProfile.php
More file actions
29 lines (23 loc) · 852 Bytes
/
updateProfile.php
File metadata and controls
29 lines (23 loc) · 852 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
include 'includes/session.php';
include 'includes/dbConnect.php';
$new_name = mysqli_real_escape_string($connection, $_POST['full_name']);
$new_gender = mysqli_real_escape_string($connection, $_POST['gender']);
$new_location = mysqli_real_escape_string($connection, $_POST['location']);
$errorCode = "";
if (strlen($new_name) < 2){
$errorCode .= "n";
}
if ($new_gender != 'M' && $new_gender != 'F' && $new_gender != 'm' && $new_gender != 'f'){
$errorCode .= "g";
}
if (strlen($errorCode) == 0){
$new_gender = strtoupper($new_gender);
$query = "UPDATE users SET full_name='$new_name', gender='$new_gender', location='$new_location' WHERE user_id='$user_id'";
$result = mysqli_query($connection, $query);
header("Location: profile.php");
}
else {
header("Location: profile.php?errorCode=$errorCode");
}
?>