Register an account







30) { $errors[] = "Your username must be 30 characters or less."; } } if (empty($_POST['user_pass'])) { $errors[] = "You must provide a password."; } else { $user_pass = validate($_POST['user_pass']); $pass_check = validate($_POST['user_pass_check']); if ($user_pass !== $pass_check) { $errors[] = "The two passwords do not match."; } } if (!empty($errors)) { echo 'Please check the following problems: '; } else { $sql = "INSERT INTO users(user_name, user_pass, user_date) VALUES(?, ?, NOW());"; $stmt = mysqli_stmt_init($dbc); if (!mysqli_stmt_prepare($stmt, $sql)) { die('Could not create account due to internal error: ' . mysqli_error($dbc)); } $pass_hash = password_hash($user_pass, PASSWORD_DEFAULT); mysqli_stmt_bind_param($stmt, "ss", $user_name, $pass_hash); mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); echo 'Account successfully registered! You can now sign in'; } } ?>