forked from jadz/php-sploits
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditprofile.php
47 lines (42 loc) · 1.77 KB
/
editprofile.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
<?php
require_once 'common.php';
require_once 'dbfuncs.php';
if(!empty($_SESSION['authed']) && $_SESSION['authed'] === true) {
if(!empty($_SESSION['userid'])) {
if($_SERVER['REQUEST_METHOD'] == "POST") {
if(!empty($_REQUEST['firstname']) && !empty($_REQUEST['surname'])
&& !empty($_REQUEST['email'])) {
$updateSQL = "update users set firstname = '" . $_REQUEST['firstname']
. "', surname = '" . $_REQUEST['surname'] . "', email='" .
$_REQUEST['email'] . "' where id = " . $_SESSION['userid'];
$updated = insertQuery($updateSQL, true);
if($updated === false) {
echo 'Unable to update your profile.';
}
else {
echo 'Details updated! Excellent.';
}
}
}
else {
$userSQL = "select email, firstname, surname from users where id = " . $_SESSION['userid'];
$userList = getSelect($userSQL);
if(empty($userList) && is_array($userList)) {
die('Unable to retrieve your settings. Doh!');
}
$user = $userList[0];
?>
<form method="POST">
<p>Edit your settings</p>
<label for="firstname">Firstname:</label>
<input name="firstname" id="firstname" value="<?=$user[1]?>" /> <br />
<label for="surname">Surname:</label>
<input name="surname" id="surname" value="<?=$user[2]?>" /> <br />
<label for="email">Email:</label>
<input name="email" id="email" value="<?=$user[0]?>" /> <br />
<input type="submit" value="Update profile">
</form>
<?
}
}
}