This repository has been archived by the owner on Jan 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
139 lines (119 loc) · 6.09 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
session_start();
include("connection.php");
include("functions.php");
$user_data = already_login($con);
$data_empty_error = $email_format_error = $uname_exists_error = $email_exists_error = $pass_mismatch_error = false;
if($_SERVER['REQUEST_METHOD'] == "POST"){
//something was posted
//collect username password email name etc.
$firstname = $_POST['first_name'];
$lastname = $_POST['last_name'];
$email = $_POST['mail'];
$username = $_POST['user_name'];
$pass = $_POST['pass_word'];
$passrepeat = $_POST['pass_word_repeat'] ?? null;
$role = $_POST['role_select'];
if(!empty($firstname) && !empty($lastname) && !empty($email) &&!empty($username) && !empty($pass) && !empty($passrepeat)){
if(filter_var($email, FILTER_VALIDATE_EMAIL)){
$result_uname = mysqli_query($con, "select * from users where username= '$username'");
$result_email = mysqli_query($con, "select * from users where email= '$email' ");
if($pass === $passrepeat){
if(mysqli_num_rows($result_uname)>0){
$uname_exists_error = true;
}else{
if(mysqli_num_rows($result_email)>0){
$email_exists_error = true;
}else{
$query = "insert into users(name,surname,username,password,email,role,confirmed) values('$firstname','$lastname','$username','$pass','$email','$role',FALSE)";
mysqli_query($con, $query);
header("Location: login.php");
}
}
}else{
$pass_mismatch_error = true;
}
}else{
$email_format_error = true;
}
}else{
$data_empty_error = true;
}
}
?>
<!DOCTYPE html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<title>Jukebox | Sign Up</title>
<link rel="shortcut icon" type="image/png" href="assets/favicon.png">
<link rel="stylesheet" href="/src/signup.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@500&family=Work+Sans:ital,wght@0,100;0,200;0,400;0,500;0,600;1,100&display=swap" rel="stylesheet">
<script src="src/main.js"></script>
<style>
body {
background-image: url('cdn/background.jpg');
background-repeat: no-repeat;
background-size: 100% 100%;
background-attachment: fixed;
font-family: "Roboto",sans-serif;
font-family: 'Work Sans', sans-serif;
}
</style>
</head>
<body>
<div class="banner">
<div class="navbar">
<div class="logo">
<a href="index.php"><img src="cdn/logo.png"></a>
</div>
<div class="menu-icons">
<a href="login.php"><img src="assets/login.png" alt="Log In"></a>
<a href="mailto:admin@jukebox.com"><img src="assets/alert.png" alt="Report a problem"></a>
</div>
</div>
<div class="content">
<div>
<form method = "POST">
<h1 class="waving-text">Please fill in your information</h1>
<input type="text" class = "input-box" placeholder= "First Name" name ="first_name">
<input type="text" class = "input-box" placeholder= "Last Name" name="last_name">
<input type="text" class = "input-box" placeholder= "yourname@example.com" name="mail">
<input type="text" class = "input-box" placeholder= "Username" name="user_name">
<input type="password" class = "input-box" placeholder= "Password" name="pass_word">
<input type="password" class = "input-box" placeholder= "Repeat Password" name="pass_word_repeat">
<select style="color:gray" name="role_select" id="role" class = "input-box styleselect">
<option value="ADMIN">Admin</option>
<option value="ORGANIZER">Organizer</option>
<option value="USER">User</option>
</select><br><br>
<input type="submit" class = "waving button" value="SIGN UP"><br><br>
<?php
if($email_format_error){
echo '<p class="error-msg"><span> Please use a valid email address </span></p>';
}
if($data_empty_error){
echo '<p class="error-msg"><span> Please fill in all required fields</span></p>';
}
if($pass_mismatch_error){
echo '<p class="error-msg"><span> Passwords do not match. Please try again</span></p>';
}
if($uname_exists_error){
echo '<p class="error-msg"><span> This username is already in use. Please try again</span></p>';
}
if($email_exists_error){
echo '<p class="error-msg"><span> This email has already been used. Please try again</span></p>';
}
?>
<a href="login.php" class = "sign-up-ref"> Already have an account? Log in </a>
</form>
</div>
<div>
<img src="assets/favicon.png" class="favi">
<h5 class = "favitext">© 2021 JUKEBOX</h5>
</div>
</div>
</div>
</body>