-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate.php
executable file
·159 lines (106 loc) · 3.44 KB
/
update.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
159
<?php
session_start();
require_once "config.php";
$_SESSION['url'] = $_SERVER['REQUEST_URI'];
if (!isset($_SESSION["un"])) {
header("Location:login.php");
}
if (isset($_SESSION['un'])) {
$username = $_SESSION['un'];
}
if (isset($_GET['user'])) {
$data = $_GET['user'];
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Profile</title>
<?php include 'linkers.php';?>
</head>
<body>
<div class="main">
<?php require 'nav2.php';?>
<div class="row log">
<div class="col-sm-10">
<div class=""><h3 style="text-align:center;"><?php echo "Update $username's Profile"; ?></h3></div>
</div>
<div class="col-sm-1">
</div>
<div class="col-sm-1">
</div>
</div>
<div class="row cspace">
<div class="col-sm-8">
<?php
if (isset($_POST['email']) && empty($_POST['statusnew'])) {
$name = $username;
$email = $_POST['email'];
$status = $_POST['statusold'];
$password = md5($status);
echo $email;
echo $status;
$lq = "SELECT * FROM `user` WHERE name='$name' AND pass='$password'";
$sq = mysqli_query($con, $lq);
$row = mysqli_fetch_array($sq);
if (!empty($row)) {
$sql = "UPDATE user SET name='$name', email='$email' WHERE name='$username'";
$send = mysqli_query($con, $sql);
//echo $send;
if ($send) {
echo "<div style=\"margin-left:250px;\" class=\"alert alert-success\">
<strong>Your Email Has Been Updated! Go To Your <a href=\"profile.php?user=$username\">Profile</a></strong>
</div><br><br><br><br>";
} else {
echo "<div style=\"margin-left:250px;\" class=\"alert alert-success\">
<strong>Wrong Password! Go To Your <a href=\"profile.php?user=$username\">Profile</a></strong>
</div><br><br><br><br>";
}
} else {
echo "<div style=\"margin-left:250px;\" class=\"alert alert-success\">
<strong>Wrong Password! Go To Your <a href=\"profile.php?user=$username\">Profile</a></strong>
</div><br><br><br><br>";
}
} else if (isset($_POST['statusnew'])) {
$name = $username;
$email = $_POST['email'];
$status1 = $_POST['statusold'];
$status2 = $_POST['statusnew'];
$passold = md5($status1);
$password = md5($status2);
$lq = "SELECT * FROM `user` WHERE name='$name' AND pass='$passold'";
$sq = mysqli_query($con, $lq);
$row = mysqli_fetch_array($sq);
if (!empty($row)) {
$sql = "UPDATE user SET name='$name', email='$email', pass='$password' WHERE name='$username'";
$send = mysqli_query($con, $sql);
if ($send) {
echo "<div style=\"margin-left:250px;\" class=\"alert alert-success\">
<strong>Your Profile Has Been Updated! Go To Your <a href=\"profile.php?user=$username\">Profile</a></strong>
</div><br><br><br><br>";
} else {
echo "<div style=\"margin-left:250px;\" class=\"alert alert-success\">
<strong>Wrong Password! Go To Your <a href=\"profile.php?user=$username\">Profile</a></strong>
</div><br><br><br><br>";
}
} else {
echo "<div style=\"margin-left:250px;\" class=\"alert alert-success\">
<strong>Wrong Password! Go To Your <a href=\"profile.php?user=$username\">Profile</a></strong>
</div><br><br><br><br>";
}
}
//echo "2";
// echo "<div style=\"margin-left:250px;\" class=\"alert alert-success\">
// <strong>Your Profile Has Been Updated! Go To Your <a href=\"profile.php?user=$username\">Profile</a></strong>
// </div><br><br><br><br>";
?>
</div>
<div class="col-sm-4">
</div>
</div>
</div><br><br><br><br>
<?php require 'footer.php';?>
</body>
</html>