Advertisement
Guest User

Untitled

a guest
Mar 21st, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require 'functions.php';
  4.  
  5. if(isset($_POST['sign-up'])){
  6.  
  7. // Email address
  8. if (isset($_POST['email_address'])){
  9. $email_address = mysql_real_escape_string(trim($_POST['email_address']));
  10. $_SESSION['status']['register']['email_address'] = $email_address;
  11. if(strlen($email_address) > 10){ // email address less than 10
  12. if(strlen($email_address) < 161){ // if longer than 160
  13.  
  14. if(email_valid($email_address) == false){ // email address invalid format
  15. $_SESSION['status']['register']['error'][] = "The email address has been put in wrong. Please check and try again.";
  16. }
  17. else{
  18. // passed min length, passed max length, passed validation
  19. }
  20. }
  21. else
  22. {
  23. $_SESSION['status']['register']['error'][] = 'The email address is too long.';
  24. }
  25. }
  26. else
  27. {
  28. $_SESSION['status']['register']['error'][] = "The email address is too short. It can't be shorter than 10 letters.";
  29. }
  30. }
  31. else
  32. {
  33. $_SESSION['status']['register']['error'][] = "You haven't put in an email address.";
  34. }
  35.  
  36. // username
  37. if (isset($_POST['username'])){
  38. $username = mysql_real_escape_string(trim($_POST['username']));
  39. $_SESSION['status']['register']['username'] = $username;
  40. if(strlen($username) > 3){
  41. if(strlen($username) < 31){
  42. if(user_exists($username) === true){
  43. $_SESSION['status']['register']['error'][] = 'That username is already taken. Sorry, please try again with a different username.';
  44. } else{
  45. // passed
  46. }
  47. } else {
  48. $_SESSION['status']['register']['error'][] = 'The username is greater than 30 characters.';
  49. }
  50. } else {
  51. $_SESSION['status']['register']['error'][] = 'The username is less than 3 characters.';
  52. }
  53. } else {
  54. $_SESSION['status']['register']['error'][] = 'The username is not entered.';
  55. }
  56.  
  57. if (isset($_POST['password'])){
  58. $password = mysql_real_escape_string(trim($_POST['password']));
  59. if(strlen($password) >= 8){
  60. $password = hash_function($password);
  61. } else {
  62. $_SESSION['status']['register']['error'][] = "Your secret password is too short. You should make a password with at least 8 letters.";
  63. }
  64.  
  65. } else {
  66. $_SESSION['status']['register']['error'][] = "You haven't put in a password.";
  67. }
  68.  
  69. if (isset($_POST['tos'])){
  70. $_SESSION['status']['register']['tos'] = $_POST['tos'];
  71. if(empty($_SESSION['status']['register']['error'])){
  72. if(register($email_address, $username, $password) === true){
  73. $_SESSION['status']['register']['success'] = true;
  74. } else {
  75. echo mysql_error();
  76. die();
  77. $_SESSION['status']['register']['error'][] = "Something went wrong. We're sorry. Please try again.";
  78. }
  79. } else {}
  80. } else {
  81. $_SESSION['status']['register']['error'][] = "You have to agree to the House Rules to be able to sign up.";
  82. }
  83.  
  84. header('Location: index.php');
  85. } else {
  86. header('Location: index.php');
  87. }
  88.  
  89. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement