-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_profile.php
36 lines (31 loc) · 1.04 KB
/
edit_profile.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
<?php
session_start();
include 'templates/db-con.php';
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$method = $_GET['method'];
$Fname = $_POST['fname'];
$Lname = $_POST['lname'];
$Contact = $_POST['contact'];
$Email = $_POST['email'];
$Uname = $_POST['uname'];
$Pwd = $_POST['pwd'];
$Role = $_POST['role'];
if($method == 'insert')
$sql = "INSERT INTO `person`(`user_id`, `pwd`, `fname`, `lname`, `email`, `contact`, `role`) VALUES('$Uname', '$Pwd', '$Fname', '$Lname', '$Email', '$Contact', '$Role');";
elseif($method == 'update')
$sql = "UPDATE person SET fname = '$Fname', lname = '$Lname', contact = '$Contact', email = '$Email', pwd = '$Pwd', role = '$Role' where user_id = '$Uname'";
if (mysqli_query($conn, $sql)) {
echo "Profile Updated Successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
if($_SESSION['role']=='admin')
header("Location: admin_view.php");
else
header("Location: profile_view.php");
exit;
?>