Created
October 25, 2013 11:52
-
-
Save robmiller/7153470 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function register() | |
{ | |
if (!empty($_POST)) { | |
$msg = ''; | |
if ($_POST['user_name']) { | |
if ($_POST['user_password_new']) { | |
if ($_POST['user_password_new'] === $_POST['user_password_repeat']) { | |
if (strlen($_POST['user_password_new']) > 5) { | |
if (strlen($_POST['user_name']) < 65 && strlen($_POST['user_name']) > 1) { | |
if (preg_match('/^[a-z\d]{2,64}$/i', $_POST['user_name'])) { | |
$user = read_user($_POST['user_name']); | |
if (!isset($user['user_name'])) { | |
if ($_POST['user_email']) { | |
if (strlen($_POST['user_email']) < 65) { | |
if (filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)) { | |
create_user(); | |
$_SESSION['msg'] = 'You are now registered so please login'; | |
header('Location: ' . $_SERVER['PHP_SELF']); | |
exit(); | |
} else $msg = 'You must provide a valid email address'; | |
} else $msg = 'Email must be less than 64 characters'; | |
} else $msg = 'Email cannot be empty'; | |
} else $msg = 'Username already exists'; | |
} else $msg = 'Username must be only a-z, A-Z, 0-9'; | |
} else $msg = 'Username must be between 2 and 64 characters'; | |
} else $msg = 'Password must be at least 6 characters'; | |
} else $msg = 'Passwords do not match'; | |
} else $msg = 'Empty Password'; | |
} else $msg = 'Empty Username'; | |
$_SESSION['msg'] = $msg; | |
} | |
return register_form(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please tell me this isn't in use in production