-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.php
More file actions
70 lines (66 loc) · 1.76 KB
/
user.php
File metadata and controls
70 lines (66 loc) · 1.76 KB
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
<?
session_start();
//connecting to the db
require "conn.php";
$user = $_SESSION["user"];
$stmt = $conn->prepare("SELECT * FROM users WHERE username = :usr");
$stmt->bindParam(":usr", $user);
$stmt->execute();
$userInfo = $stmt->fetch(PDO::FETCH_OBJ);
function del(){
$stmt = $conn->prepare("DELETE FROM users WHERE username=:usr");
$stmt->bindParam(":usr", $user);
$stmt->execute();
if($stmt){
header('Location: ');
}else{
header('Location: ?act=error');
}
}
function res(){
$stmt = $conn->prepare("UPDATE users SET level = 1 WHERE username = :usr");
$stmt->bindParam(":usr", $user);
$stmt->execute();
if($stmt){
header('Location: ?act=done');
}else{
header('Location: ?act=error');
}
}
if(isset($_GET["act"])){
$act = $_GET["act"];
switch($act){
case "del":
del();
break;
case "res":
res();
break;
case "error":
echo "<h1>Something went wrong</h1>";
break;
default:
echo "<h1>Something went wrong</h1>";
break;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Riddles Without Vitae</title>
<link rel="stylesheet" type="text/css" href="user.css" />
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<h1><?=$user?></h1>
<p>This is your profile page. There will never be clues here.</p>
<p>You are on <a href=/rwv/vamos.php?level=<?=$userInfo->level?>>level <?=$userInfo->level?></a>.</p>
<br>
<br>
<h2>Danger Zone</h2>
<h3><a id=del href="?act=del">Delete account</a></h3>
<h3><a id=res href="?act=res">Reset progress</a></h3>
</body>
</html>