-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.php
More file actions
92 lines (77 loc) · 3.2 KB
/
Copy pathsignup.php
File metadata and controls
92 lines (77 loc) · 3.2 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once __DIR__ . '/includes/init.php';
// block access when already logged in
if(isset($_SESSION['logged_in']) && $_SESSION['logged_in']){
header('Location: ./index.php');
die();
}
if($_SERVER['REQUEST_METHOD'] === 'POST'){
$username = $_POST['username'];
$email = $_POST['email'];
$pwd = $_POST['pwd'];
try{
$dbconn = new DbConn();
$pdo = $dbconn->getPdo();
$signup = new Signup($pdo, $username, $email, $pwd);
$signup->validate($pdo, $username, $email, $pwd); // run validation
$errors = $signup->errors;
// user registered, back to index/login page
if(empty($errors)){
header('Location: ./index.php');
die();
}
} catch(PDOException $e){
die("Query failed: {$e->getMessage()}");
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description" content="A simple, no-fuss to-do list web app designed to help you stay organized and remember what matters.">
<link rel="icon" type="image/png" href="./images/temp-logo.png">
<title>Sign up</title>
<!-- opengraph -->
<meta property="og:title" content="Quest Log: rpg-themed todo list web application">
<meta property="og:description" content="A simple, no-fuss to-do list web app designed to help you stay organized and remember what matters.">
<meta property="og:url" content="https://questlog.tenkyuu.dev">
<meta property="og:image" content="https://questlog.tenkyuu.dev/images/app-screenshot.png">
<link href="./dist/rpgui.css" rel="stylesheet" type="text/css" >
<script src="./dist/rpgui.js"></script>
</head>
<body class="rpgui-content" style="display: flex; justify-content: center;">
<div class="rpgui-container framed" style="margin: 32px 0; width: 95%; height: fit-content; max-width: 600px;">
<main>
<h1 style="text-align: center;">Sign up</h1>
<p>Some recommendations on creating an account:</p>
<ul>
<li>Choose a password that is atleast 12 characters long.</li>
<li>Use a strong password. Combination of uppercase, lowercase, numbers, and special characters.</li>
</ul>
<div class="rpgui-container framed-grey" style="width: 90%; margin: auto;">
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF'])?>" method="POST">
<input type="text" name="username" placeholder="username">
<input type="text" name="email" placeholder="email">
<input type="password" name="pwd" placeholder="password">
<div style="text-align: right;">
<button class="rpgui-button" type="submit">Register</button>
</div>
</form>
</div>
<?php if(!empty($errors)): ?>
<div>
<?php foreach($errors as $error): ?>
<p style="color: red;"><?php echo htmlspecialchars($error); ?></p>
<?php endforeach; ?>
</div>
<?php endif; ?>
<p>Already have an account? <a href="./login.php">Log in</a></p>
</main>
</div>
</body>
</html>