-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateaccount.php
69 lines (58 loc) Β· 1.72 KB
/
updateaccount.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
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
$page_title = "Update user details";
require_once ('includes/header.php');
require_once('includes/database.php');
//retrieve all fields from the previous page
$user_id = $_GET['id'];
$user_name = $_GET['username'];
$full_name = $_GET['name'];
$user_email = $_GET['email'];
$password = $_GET['password'];
//update statement
$query_str = "UPDATE users SET
user_name='$user_name',
user_full_name='$full_name',
user_email='$user_email',
user_password='$password'
WHERE user_id='$user_id'";
//execute the query
$result = @$conn->query($query_str);
//Handle selection errors
if (!$result) {
$errno = $conn->errno;
$errmsg = $conn->error;
echo "Connection Failed with: $errno, $errmsg<br/>\n";
exit;
}else {
?>
<?php ?>
<div class="container wrapper">
<h2 class="text-center text-success">Your account has been updated</h2>
</div>
<?php
//The SQL select statement
$query = "SELECT * FROM users WHERE user_name='$user_name' AND user_password='$password'";
//Execute the query
$result = @$conn->query($query);
if($result -> num_rows){
session_destroy();
//It is a valid user. Need to store the user in Session Variables
session_start();
$_SESSION['login'] = $user_name;
$result_row = $result->fetch_assoc();
$_SESSION['role'] = $result_row['user_role'];
$_SESSION['name'] = $result_row['user_full_name'];
$_SESSION['id'] = $result_row['user_id'];
//update the login status
$login_status = 1;
}
header( "Refresh:5; url=useraccount.php", true, 303);
}
// close the connection.
$conn->close();
include ('includes/footer.php');
?>