-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
104 lines (101 loc) · 2.98 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<html lang="en">
<head>
<title>Car Purchasing</title>
<link rel="stylesheet" type="text/css" href="style/reset.css">
<link rel="stylesheet" type="text/css" href="style/responsive.css">
</head>
<body>
<section class="">
<?php
include 'header.php';
include 'connection.php';
$user_id = $_SESSION['cid'];
$qy = "SELECT * FROM customers WHERE Customer_id='$user_id'";
$log = $conn->query($qy);
$num = $log->num_rows;
$row = $log->fetch_assoc();
if($num > 0){
$name = $row['Name'];
$address = $row['Address'];
$phone = $row['Phone_number'];
$email = $row['Email_Address'];
$password = $row['Password'];
$gender= $row['Gender'];
}
?>
<section class="listings">
<div class="wrapper">
<h3>Update Your Details Here</h3>
<form method="post">
<table>
<tr>
<td>Name:</td>
<td><input type="text" name="name" required value="<?php echo $name;?>"></td>
</tr>
<tr>
<td>Phone Number:</td>
<td><input type="text" name="phone" required value="<?php echo $phone;?>"></td>
</tr>
<tr>
<td>Email Address:</td>
<td><input type="email" name="email" required value="<?php echo $email;?>"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" required value="<?php echo $password;?>"></td>
</tr>
<tr>
<td>Gender:</td>
<td>
<select name="gender">
<option> Male </option>
<option> Female </option>
<option> Other </option>
<option> Prefer Not To Specify </option>
</select>
</td>
</tr>
<tr>
<td>Address:</td>
<td><input type="text" name="address" required value="<?php echo $address;?>"></td>
</tr>
<tr>
<td colspan="2" style="text-align:right"><input type="submit" name="save" value="Submit Details"></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['save'])){
$namea = $_POST['name'];
$passworda = $_POST['password'];
$gendera = $_POST['gender'];
$emaila = $_POST['email'];
$phonea = $_POST['phone'];
$addressa = $_POST['address'];
$qry = "UPDATE customers SET
Password='$passworda',
Phone_number='$phonea',
Name='$namea',
Address='$addressa',
Email_Address='$emaila',
Gender='$gendera' WHERE Customer_id='$user_id'";
$result = $conn->query($qry);
if($result == TRUE){
echo "<script type = \"text/javascript\">
alert(\"Successfully Update\");
window.location = (\"index.php\")
</script>";
} else{
echo "<script type = \"text/javascript\">
alert(\"Updation Failed. Try Again\");
window.location = (\"index.php\")
</script>";
}
}
?>
</div>
</section>
</section>
</body>
</html>