-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount.php
36 lines (35 loc) · 1.27 KB
/
account.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
<?php
$my_email = openssl_decrypt($_SESSION['token'], "AES-128-CTR", "11112000", 0, "1234567890123456");
$pdo = new PDO('mysql:host=localhost;dbname=users','root','pwd');
$query = $pdo->prepare("select * from chatters where email=?");
$query->bindValue(1, $my_email);
$query->execute();
$result = $query->fetch(PDO::FETCH_ASSOC);
$number = $result['id']%70 + 1;
echo "<div class='account-container'>
<h1 class='username'>My account</h1>
<div class='account-infos-container'>
<img src='https://i.pravatar.cc/1000?img=".$number."'/>
<div class='account-infos'>
<span class='fullname'>".$result['first_name']." ".$result['last_name']."</span>
<span class='email'>".$result['email']."</span>
<button class='logout' onclick='logout()'>
Logout
</button>
</div>
</div>
</div>"
?>
<script>
function logout() {
let xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if(this.status==200 && this.readyState==4) {
console.log(this.response);
window.location.href = "login.php"
}
}
xmlhttp.open('GET', 'logout.php', true);
xmlhttp.send();
}
</script>