jun 12
This commit is contained in:
52
php/register.php
Normal file
52
php/register.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
require 'connect.inc.php';
|
||||
require 'core.inc.php';
|
||||
|
||||
if (!loggedin()) {
|
||||
if (
|
||||
isset($_POST['name']) && isset($_POST['email'])
|
||||
&& isset($_POST['password']) && isset($_POST['password_again'])
|
||||
) {
|
||||
$name = $_POST['name'];
|
||||
$email = $_POST['email'];
|
||||
$password = $_POST['password'];
|
||||
$password_again = $_POST['password_again'];
|
||||
$password_hash = md5($password);
|
||||
$upperCase = preg_match('/[A-Z]/', $password);
|
||||
|
||||
if (
|
||||
!empty($name) && !empty($password) && !empty($password_again) &&
|
||||
!empty($email)
|
||||
) {
|
||||
if (strlen($name) > 30) {
|
||||
echo 'Please ahear to maxlength of fields';
|
||||
} else {
|
||||
if ($password != $password_again) {
|
||||
echo 'Passwords do not match';
|
||||
}elseif (strlen($password) < 6){
|
||||
echo 'Password is weak!';
|
||||
}
|
||||
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, $email) . "','" . mysqli_real_escape_string($con, $password_hash) . "')";
|
||||
if ($query_run = mysqli_query($con, $query)) {
|
||||
echo '<script>alert("You are registerd!")</script>';
|
||||
header('Location: ../index.html');
|
||||
} else {
|
||||
echo 'We could not register you!';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo 'All fields are required';
|
||||
}
|
||||
}
|
||||
} else if (loggedin()) {
|
||||
echo 'You are already registered and logged in !';
|
||||
}
|
||||
Reference in New Issue
Block a user