From df49a36e140acc211fdc31480d40281404110310 Mon Sep 17 00:00:00 2001 From: Cflip <36554078+cflip@users.noreply.github.com> Date: Fri, 22 Jan 2021 20:45:43 -0700 Subject: Inital commit with existing code --- register.php | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 register.php (limited to 'register.php') diff --git a/register.php b/register.php new file mode 100644 index 0000000..8f74aa9 --- /dev/null +++ b/register.php @@ -0,0 +1,81 @@ + + + + cflip.net forum + + + + +
+

Register an account

+ +
+ +
+
+
+
+
+
+ + + '; +} else { + $errors = array(); + + if (isset($_POST['user_name'])) { + if (!ctype_alnum($_POST['user_name'])) { + $errors[] = 'Invalid username. Only letters and numbers are supported.'; + } + if (strlen($_POST['user_name']) > 30) { + $errors[] = 'Username must be 30 characters or less.'; + } + } else { + $errors[] = 'Please provide a username.'; + } + + if (isset($_POST['user_pass'])) { + if ($_POST['user_pass'] != $_POST['user_pass_check']) { + $errors[] = 'The two passwords do not match.'; + } + } else { + $errors[] = 'Please provide a password.'; + } + + if (!empty($errors)) { + echo 'Please check the following problems: '; + } else { + $sql = "INSERT INTO users(user_name, user_pass, user_date) + VALUES('" . mysqli_real_escape_string($dbc, $_POST['user_name']) . "', + '" . sha1($_POST['user_pass']) . "', + NOW()) + "; + + $result = mysqli_query($dbc, $sql); + if (!$result) { + echo 'Failed to register account due to internal error.'; + echo mysqli_error($dbc); + } else { + echo 'Account successfully created!'; + } + } +} + +?> +
+ +
+ + \ No newline at end of file -- cgit v1.2.3