-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
97 lines (95 loc) · 3.93 KB
/
signup.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
session_start();
if (isset($_SESSION['user_id'])) {
header('Location: /crud_add_pdf_project/dashboard.php');
}
require 'database.php';
$message = '';
if (!empty($_POST['email']) && !empty($_POST['password'])) {
$sql = "INSERT INTO users (email, password, username, fullname, phonenumber) VALUES (:email, :password, :username, :fullname, :phonenumber)";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':email', $_POST['email']);
$password = password_hash($_POST['password'], PASSWORD_BCRYPT);
$stmt->bindParam(':password', $password);
$stmt->bindParam(':username', $_POST['username']);
$stmt->bindParam(':fullname', $_POST['fullname']);
$stmt->bindParam(':phonenumber', $_POST['phonenumber']);
if ($stmt->execute()) {
echo '<script>
Swal.fire({
icon: "success",
title: "Successfully created new user!",
showConfirmButton: false,
timer: 2000
}).then(function() {
window.location.href = "/crud_add_pdf_project/login.php";
});
</script>';
$message = 'Successfully created new user';
header('Location: /crud_add_pdf_project/login.php');
} else {
echo '<script>
Swal.fire({
icon: "error",
title: "Oops...",
text: "Sorry there must have been an issue creating your account",
});
</script>';
$message = 'Sorry there must have been an issue creating your account';
}
}
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8" />
<title>SignUp Form | PentaTech-IT-Solutions</title>
<link rel="stylesheet" href="./assets/css/style2.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.all.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="title">Registration</div>
<div><?php if(!empty($message)): ?>
<p><?= $message ?></p>
<?php endif; ?>
</div>
<div class="content">
<form action="signup.php" method="post">
<div class="user-details">
<div class="input-box">
<span class="details">Full Name</span>
<input type="text" placeholder="Enter your name" name="fullname" required />
</div>
<div class="input-box">
<span class="details">Username</span>
<input type="text" placeholder="Enter your username" name="username" required />
</div>
<div class="input-box">
<span class="details">Email</span>
<input type="email" placeholder="Enter your email" name="email" required />
</div>
<div class="input-box">
<span class="details">Phone Number</span>
<input type="text" placeholder="Enter your phone number (12 digits)" name="phonenumber" maxlength="12" required />
</div>
<div class="input-box">
<span class="details">Password</span>
<input type="password" placeholder="Enter your password" name="password" minlength="6" required />
</div>
<div class="input-box">
<span class="details">Confirm Password</span>
<input type="password" placeholder="Confirm your password" name="confirmpassword" minlength="6" required />
</div>
</div>
<div class="button">
<input type="submit" name="signup-button" value="Register" />
</div>
<p>Already have an account? <a href="/crud_add_pdf_project/login.php">Log in</a></p>
</form>
</div>
</div>
</body>
</html>