68 lines
3.3 KiB
PHP
68 lines
3.3 KiB
PHP
<?php
|
|
require 'connect.inc.php';
|
|
require 'core.inc.php';
|
|
|
|
|
|
if (
|
|
isset($_POST['name']) && isset($_POST['surname']) && isset($_POST['email'])
|
|
&& isset($_POST['password']) && isset($_POST['password_again']) && isset($_POST['birth_day'])
|
|
&& isset($_POST['birth_month']) && isset($_POST['birth_year']) && isset($_POST['city']) && isset($_POST['admin'])
|
|
) {
|
|
$admin = $_POST['admin'];
|
|
$name = $_POST['name'];
|
|
$surname = $_POST['surname'];
|
|
$email = $_POST['email'];
|
|
$password = $_POST['password'];
|
|
$password_again = $_POST['password_again'];
|
|
$password_hash = md5($password);
|
|
$birth_day = $_POST['birth_day'];
|
|
$birth_month = $_POST['birth_month'];
|
|
$birth_year = $_POST['birth_year'];
|
|
$city = $_POST['city'];
|
|
|
|
if (
|
|
!empty($name) && !empty($password) && !empty($password_again) && isset($admin)&&
|
|
!empty($email) && !empty($birth_day) && !empty($birth_month) && !empty($birth_year) && !empty($city)
|
|
) {
|
|
if (strlen($name) > 30) {
|
|
echo 'Please ahear to maxlength of fields';
|
|
} elseif (preg_match("/\d/", $name) || preg_match("/\W/", $name)) {
|
|
echo 'Your name must contains only letters!';
|
|
} else {
|
|
if ($password != $password_again) {
|
|
echo 'Passwords do not match';
|
|
} elseif (strlen($password) < 8) {
|
|
echo 'Password is weak!';
|
|
} elseif (!preg_match("/\d/", $password)) {
|
|
echo 'Password must have one number at least!';
|
|
} elseif (!preg_match("#[A-Z]+#", $password)) {
|
|
echo 'Password must have one capital letter at least!';
|
|
} elseif (!preg_match("#[a-z]+#", $password)) {
|
|
echo 'Password must have one letter at least!';
|
|
} elseif (!preg_match("/\W/", $password)) {
|
|
echo 'Password must have one special carachter at least!';
|
|
} else {
|
|
$query = "SELECT `email` FROM `globaly_accounts` WHERE `email` ='$email'";
|
|
$query_run = mysqli_query($con, $query);
|
|
if (mysqli_num_rows($query_run) == 1) {
|
|
echo 'The email ' . $email . 'already exists';
|
|
} else {
|
|
$query = "INSERT INTO `globaly_accounts` VALUES (NULL ,'" . mysqli_real_escape_string($con, $name) .
|
|
"','" . mysqli_real_escape_string($con, $surname) . "','" . mysqli_real_escape_string($con, $email) . "','" . mysqli_real_escape_string($con, $password_hash) . "','" . mysqli_real_escape_string($con, $city) . "','" .
|
|
mysqli_real_escape_string($con, $birth_day) . "','" . mysqli_real_escape_string($con, $birth_month) . "','" . mysqli_real_escape_string($con, $birth_year) . "','" . mysqli_real_escape_string($con, $admin) ."')";
|
|
if ($query_run = mysqli_query($con, $query)) {
|
|
echo '<script type="text/javascript">
|
|
alert("You have successfully added the user!");
|
|
window.location.href = "../add_user.php";
|
|
</script>';
|
|
} else {
|
|
echo 'We could not register you!';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
echo 'All fields are required';
|
|
}
|
|
}
|