Advertisement
Guest User

Register RS-SC

a guest
May 19th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. <?php
  2. if ($Config["Regopen"] != 0) {
  3. if (isset($_POST['sendForm'])) {
  4.  
  5. $username = $_POST['username'];
  6. $password = $_POST['password'];
  7. $cpassword = $_POST['cpassword'];
  8.  
  9. $encryptPassword = sha1($password);
  10.  
  11. if (!empty($username) && (!empty($password))) {
  12. if ($password == $cpassword) {
  13.  
  14. if (strlen($username) < $strLongUser) {
  15. if (strlen($password) < $strLongPass) {
  16. $fetchUsername = "SELECT * FROM useraccounts WHERE username = '$username'";
  17. if ($stmt = $conn->prepare($fetchUsername)) {
  18. $stmt->execute();
  19. $stmt->store_result();
  20. if ($stmt->num_rows == 0) {
  21. $stmt->close();
  22. if ($stmt = $conn->prepare("INSERT INTO useraccounts (username, password) VALUES (?, ?)")) {
  23. $stmt->bind_param('ss', $username, $encryptPassword);
  24.  
  25. $rUser = $_POST['username'];
  26. $rPass = $_POST['password'];
  27.  
  28. $stmt->execute();
  29. echo '<div class="alert alert-success"><i class="fa fa-check"></i> You have succesfully registered, '.$rUser.'.</div>';
  30. } else {
  31. printf("Prepared Statement Error: %s\n", $conn->error);
  32. }
  33. } else {
  34. echo '<div class="alert alert-danger"><i class="fa fa-times"></i> This username was already taken.</div>';
  35. }
  36. }
  37. } else {
  38. echo '<div class="alert alert-danger"><i class="fa fa-times"></i> The password may consist out of a maximum of 20 characters.</div>';
  39. }
  40. } else {
  41. echo '<div class="alert alert-danger"><i class="fa fa-times"></i> The username may consist out of a maximum of 16 characters.</div>';
  42. }
  43.  
  44. } else {
  45. echo '<div class="alert alert-danger"><i class="fa fa-times"></i> Please make sure the passwords are equal.</div>';
  46. }
  47. } else {
  48. echo '<div class="alert alert-danger"><i class="fa fa-times"></i> Error: Please fill in your username and password.</i></div>';
  49. }
  50. }
  51. } else {
  52. echo '<div class="alert alert-warning"><i class="fa fa-times"></i> Sorry, but registration has been disabled.</div>';
  53. }
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement