-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddUser.php
More file actions
33 lines (31 loc) · 1.06 KB
/
addUser.php
File metadata and controls
33 lines (31 loc) · 1.06 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
<?php
require "Query.php";
Query::connectDatabase();
$name = $_POST['name'];
$mail = $_POST['mail'];
$password = $_POST['password'];
if(empty($_POST['name']) || empty($_POST['password']) || empty($_POST['mail']) )
{
echo "<script>alert('You have an empty field.');</script>";
header("Refresh:0; url=register.php"); // go back to the register page
}
else{
$query = "SELECT USERS.id
FROM USERS
WHERE USERS.mail = '$mail'";
$result = Query::$conn->query($query);
if(mysqli_num_rows($result) != 0){
echo "<script>alert('Entered e-mail already has an account!');</script>";
header("Refresh:0; url=register.php");
}
else{
$query = "INSERT INTO USERS (password, mail , name) VALUES ('$password', '$mail', '$name')";
if (Query::$conn->query($query) === TRUE) {
echo "<script>alert('You have successfully registered!');</script>";
} else {
echo "<script>alert('error');</script>";
}
}
header("Refresh:0; url=index.php");
}
?>