-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.php
More file actions
executable file
·69 lines (55 loc) · 2.07 KB
/
Copy pathsignup.php
File metadata and controls
executable file
·69 lines (55 loc) · 2.07 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
<?php
$page_title = "Sign Up";
$page_js = "auth.js";
include 'includes/header.php';
// Redirect if already logged in
if (is_logged_in()) {
header("Location: index.php");
exit;
}
// Process signup form
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = sanitize_input($_POST['username']);
$email = sanitize_input($_POST['email']);
$password = $_POST['password']; // Don't sanitize password
// Additional validation could be done here
if (register_user($username, $email, $password)) {
// Log the user in
login_user($username, $password);
// Redirect to home page
header("Location: index.php");
exit;
} else {
$error = "Username or email already exists";
}
}
?>
<div class="form-container">
<h2 class="form-title">Create an Account</h2>
<?php if (isset($error)): ?>
<div class="alert alert-danger"><?php echo $error; ?></div>
<?php endif; ?>
<form id="signup-form" method="post" action="">
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="form-group">
<label for="confirm-password">Confirm Password</label>
<input type="password" class="form-control" id="confirm-password" name="confirm_password" required>
</div>
<button type="submit" class="btn btn-block">Sign Up</button>
<div class="form-footer">
<p>Already have an account? <a href="login.php">Login</a></p>
</div>
</form>
</div>
<?php include 'includes/footer.php'; ?>