Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.50 KB | None | 0 0
  1. <div id="maincontent">
  2.  
  3. <h1>WoW Registration Form</h1>
  4. <p>Please fill out the form below to create a new account. Note by clicking "Create Account" you are agreeing to the rules outlined <a href="insert_rules_page">here.</a></p>
  5. <br />
  6. <div id="reg">
  7. <form method="post" action="insert.php">
  8. Username:<br />
  9. <input name="username" type="text" maxlength="14" />
  10. <br /><br />
  11. Password:<br />
  12. <input name="pw" type="password" maxlength="12" />
  13. <br /><br />
  14. Email:<br />
  15. <input name="email" type="text" maxlength="50" />
  16. <br /><br />
  17. <input name="tbc" type="checkbox" checked="checked" /> TBC <br />
  18. <br /><br />
  19. <br />
  20. <br />
  21. <input name="Submit" type="submit" value="Create Account" />
  22. </form>
  23. <br />
  24. </div><!--reg-->
  25.  
  26. </div><!--MainContent-->
  27.  
  28.  
  29. --------------------------------
  30.  
  31. insert.php file
  32.  
  33. ---------------------------------
  34.  
  35.  
  36. <?php
  37.  
  38. // Configuration.
  39. // Realm database.
  40. $r_db = "realmd";
  41. // IP (and port).
  42. $ip = "localhost:3306";
  43. // Username.
  44. $user = "trinity";
  45. // Password.
  46. $pass = "trinity";
  47.  
  48. function error_s($text) {
  49. echo("<p>" . $text);
  50. };
  51.  
  52. $user_chars = "#[^a-zA-Z0-9_\-]#";
  53. $email_chars = "/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/";
  54.  
  55. if ( !isset($_POST['username']) || !isset($_POST['pw']) || !isset($_POST['email']) )
  56. {
  57. echo "User/Pass/Email not passed.";
  58. return;
  59. }
  60.  
  61. $con = @mysql_connect($ip, $user, $pass);
  62. if (!$con) {
  63. error_s("Unable to connect to database: " . mysql_error());
  64. };
  65.  
  66. if (!empty($_POST)) {
  67. if ((empty($_POST["username"]))||(empty($_POST["pw"]))||(empty($_POST["email"]))||(empty($_POST["tbc"])) ) {
  68. error_s("You did not enter all the required information.");
  69. exit();
  70. } else {
  71. $username = strtoupper($_POST["username"]);
  72. $pw = strtoupper($_POST["pw"]);
  73. $email = strtoupper($_POST["email"]);
  74. if (strlen($username) < 5) {
  75. error_s("Username too short.");
  76. exit();
  77. };
  78. if (strlen($username) > 14) {
  79. error_s("Username too long.");
  80. exit();
  81. };
  82. if (strlen($pw) < 6) {
  83. error_s("Password too short.");
  84. exit();
  85. };
  86. if (strlen($pw) > 12) {
  87. error_s("Password too long.");
  88. exit();
  89. };
  90. if (strlen($email) < 10) {
  91. error_s("Email was too short.");
  92. exit();
  93. };
  94. if (strlen($email) > 50) {
  95. error_s("Email was too long.");
  96. exit();
  97. };
  98. if (preg_match($user_chars,$username)) {
  99. error_s("Username contained illegal characters.");
  100. exit();
  101. };
  102. if (preg_match($user_chars,$pw)) {
  103. error_s("Password contained illegal characters.");
  104. exit();
  105. };
  106. if (!preg_match($email_chars,$email)) {
  107. error_s("Email was in an incorrect format.");
  108. exit();
  109. };
  110. if ($_POST['tbc'] != "on") {
  111. $tbc = "0";
  112. } else {
  113. $tbc = "1";
  114. };
  115. $username = mysql_real_escape_string($username);
  116. $pw = mysql_real_escape_string($pw);
  117. $email = mysql_real_escape_string($email);
  118. $qry = @mysql_query("select username from " . mysql_real_escape_string($r_db) . ".account where username = '" . $username . "'", $con);
  119. if (!$qry) {
  120. error_s("Error querying database: " . mysql_error());
  121. };
  122. if ($existing_username = mysql_fetch_assoc($qry)) {
  123. foreach ($existing_username as $key => $value) {
  124. $existing_username = $value;
  125. };
  126. };
  127. $existing_username = strtoupper($existing_username);
  128. if ($existing_username == strtoupper($_POST['username'])) {
  129. error_s("That username is already taken.");
  130. exit();
  131. };
  132. unset($qry);
  133. $qry = @mysql_query("select email from " . mysql_real_escape_string($r_db) . ".account where email = '" . $email . "'", $con);
  134. if (!$qry) {
  135. error_s("Error querying database: " . mysql_error());
  136. };
  137. if ($existing_email = mysql_fetch_assoc($qry)) {
  138. foreach ($existing_email as $key => $value) {
  139. $existing_email = $value;
  140. };
  141. };
  142. if ($existing_email == $_POST['email']) {
  143. error_s("That email is already in use.");
  144. exit();
  145. };
  146. unset($qry);
  147. $sha_pass_hash = sha1(strtoupper($username) . ":" . strtoupper($pw));
  148. $register_sql = "insert into " . mysql_real_escape_string($r_db) . ".account (username, sha_pass_hash, email, expansion) values (upper('" . $username . "'),'" . $sha_pass_hash . "','" . $email . "','" . $tbc . "')";
  149. $qry = @mysql_query($register_sql, $con);
  150. if (!$qry) {
  151. error_s("Error creating account: " . mysql_error());
  152. };
  153. echo("Account successfully created.");
  154. exit();
  155. };
  156. } else {
  157. echo($page);
  158. };
  159.  
  160. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement