-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_profile.php
158 lines (154 loc) · 5.8 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
include("connection.php");
session_start();
//if user is not logged in
if(!isset($_SESSION['username'])){
header('location:login.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>MecBooksCart|Edit Profile</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<style>
.form-container {
display:table;
max-width:900px;
width:90%;
margin:0 auto;
box-shadow:100px 100px 100px 100px rgba(0,0,0,0.1);
}
form {
display:table-cell;
width:400px;
background-color:#ffffff;
padding:40px 60px 100px 60px;
color:#505e6c;
}
@media (max-width:991px) {
form {
padding:40px 40px 100px 40px;
}
}
form h2 {
font-size:30px;
line-height:1.5;
margin-bottom:30px;
}
form .form-control {
background:#f7f9fc;
border:none;
border-bottom:1px solid #dfe7f1;
border-radius:0;
box-shadow:none;
outline:none;
color:inherit;
text-indent:6px;
height:40px;
}
form .form-check {
font-size:13px;
line-height:20px;
}
form .btn-primary {
background:#f4476b;
border:none;
border-radius:4px;
padding:11px;
box-shadow:none;
margin-top:35px;
text-shadow:none;
outline:none !important;
}
form .btn-primary:hover, form .btn-primary:active, .btn-primary:active:hover {
background:#eb3b60;
}
form .already {
display:block;
text-align:center;
font-size:18px;
color:#6f7a85;
opacity:0.9;
text-decoration:none;
}
form .input-group-addon{
background:black;
color: white;
}
</style>
</head>
<body>
<!-- Header -->
<?php
include 'navbar.php';
//if user is not logged in
if(!isset($_SESSION['username'])){
header('location:login.php');
}
$username=$_SESSION['username'];
$fetch=mysqli_query($con,"SELECT * FROM user WHERE username='$username'");
if($fetch && $fetch->num_rows>0){
while($row=mysqli_fetch_array($fetch)){
?>
<div class="form-container">
<form id="modifyform" method="post" >
<div class="form-group">
<h2>Username : <?php echo $row["username"];?> </h2>
<input type="hidden" name="username" value="<?php echo $row["username"];?>">
</div>
<div class="form-group">
<b>Full Name:</b><br>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input type="text" class="form-control" value="<?php echo $row["fullname"];?>" name="fullname" required >
</div>
</div>
<div class="form-group">
<b>Phone:</b><br>
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-phone"></i></span>
<input type="text" class="form-control" value="<?php echo $row["phone"];?>" name="phone" required>
</div>
</div>
<div class="form-group">
<button class="btn btn-primary btn-block" name="user_modify" type="submit" >Modify Details</button>
</div>
</form>
</div>
<?php
}
}
if(isset($_POST['user_modify'])){
$fullname=test_input($_POST['fullname']);
$phone=test_input($_POST['phone']);
$update=mysqli_query($con, "UPDATE user SET fullname='$fullname', phone='$phone' WHERE username='$username' ");
if($update){
?>
<script>
alert("Details modified successfully.");
window.location.replace("edit_profile.php");
</script>
<?php
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<!-- Footer -->
<?php
include 'footer.php';
?>
</body>
</html>