-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcust_update_profile.php
103 lines (96 loc) · 5.07 KB
/
cust_update_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
<!DOCTYPE html>
<html lang="en">
<head>
<?php
session_start();
include("conn_db.php");
if(!isset($_SESSION["cid"])){
header("location: restricted.php");
exit(1);
}
if(isset($_POST["upd_confirm"])){
$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
$email = $_POST["email"];
$gender = $_POST["gender"];
$type = $_POST["type"];
$query = "UPDATE customer SET c_firstname = '{$firstname}', c_lastname = '{$lastname}', c_email = '{$email}', c_gender = '{$gender}', c_type = '{$type}' WHERE c_id = {$_SESSION['cid']}";
$result = $mysqli -> query($query);
if($result){
$_SESSION["firstname"] = $firstname;
$_SESSION["lastname"] = $lastname;
header("location: cust_profile.php?up_prf=1");
}else{
header("location: cust_profile.php?up_prf=0");
}
exit(1);
}
include('head.php');
?>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/main.css" rel="stylesheet">
<link href="css/login.css" rel="stylesheet">
<title>Update profile | EATERIO</title>
</head>
<body class="d-flex flex-column h-100">
<?php include('nav_header.php')?>
<div class="container form-signin mt-auto w-50">
<a class="nav nav-item text-decoration-none text-muted" href="#" onclick="history.back();">
<i class="bi bi-arrow-left-square me-2"></i>Go back
</a>
<?php
//Select customer record from database
$query = "SELECT c_firstname,c_lastname,c_email,c_gender,c_type FROM customer WHERE c_id = {$_SESSION['cid']} LIMIT 0,1";
$result = $mysqli ->query($query);
$row = $result -> fetch_array();
?>
<form method="POST" action="cust_update_profile.php" class="form-floating">
<h2 class="mt-4 mb-3 fw-normal text-bold"><i class="bi bi-pencil-square me-2"></i>Update Profile</h2>
<div class="form-floating mb-2">
<input type="text" class="form-control" id="firstname" placeholder="First Name" name="firstname"
value="<?php echo $row["c_firstname"];?>" required>
<label for="firstname">First Name</label>
</div>
<div class="form-floating mb-2">
<input type="text" class="form-control" id="lastname" placeholder="Last Name" value="<?php echo $row["c_lastname"];?>" name="lastname" required>
<label for="lastname">Last Name</label>
</div>
<div class="form-floating mb-2">
<input type="email" class="form-control" id="email" placeholder="E-mail" name="email" value="<?php echo $row["c_email"];?>" required>
<label for="email">E-mail</label>
</div>
<div class="form-floating">
<select class="form-select mb-2" id="gender" name="gender">
<option value="M" <?php if($row["c_gender"]=="M"){echo "selected";}?>>Male</option>
<option value="F" <?php if($row["c_gender"]=="F"){echo "selected";}?>>Female</option>
<option value="N" <?php if($row["c_gender"]=="N"){echo "selected";}?>>Non-binary</option>
</select>
<label for="gender">Your Gender</label>
</div>
<div class="form-floating">
<select class="form-select mb-2" id="type" name="type">
<option value="STD" <?php if($row["c_type"]=="STD"){echo "selected";}?>>Student</option>
<option value="INS" <?php if($row["c_type"]=="INS"){echo "selected";}?>>Professor</option>
<option value="TAS" <?php if($row["c_type"]=="TAS"){echo "selected";}?>>Teaching Assistant</option>
<option value="STF" <?php if($row["c_type"]=="STF"){echo "selected";}?>>Faculty Staff</option>
<option value="GUE" <?php if($row["c_type"]=="GUE"){echo "selected";}?>>Visitor</option>
<option value="OTH" <?php if($row["c_type"]=="OTH"){echo "selected";}?>>Other</option>
</select>
<label for="gender">Your role</label>
</div>
<button class="w-100 btn btn-success mb-3" name="upd_confirm" type="submit">Update Profile</button>
</form>
</div>
<footer
class="footer d-flex flex-wrap justify-content-between align-items-center px-5 py-3 mt-auto bg-secondary text-light">
<span class="smaller-font">© 2021 SeriousEater Group<br /><span class="xsmall-font">Paphana Y. Sirada C.
Thanakit L.</span></span>
<ul class="nav justify-content-end list-unstyled d-flex">
<li class="ms-3"><a class="text-light" target="_blank" href="https://github.com/waterthatfrozen/EATERIO"><i
class="bi bi-github"></i></a></li>
</ul>
</footer>
</body>
</html>