Guest User

Untitled

a guest
Oct 15th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. <?php
  2. if (@$_POST["register"] != "1") {
  3. ?>
  4. <div id="main">
  5. <center>
  6. <div class="h3">Registration</div>
  7. <div class="mainbox">
  8. <table cellspacing=1 cellpadding=5>
  9. <tr><td class="listtitle" colspan=2><center><span class='title2'></span></center></td></tr>
  10. <form action="?page=register" method="POST">
  11. <tr><td class="list" align="left">Username:</td>
  12. <td class="list"><input type="text" name="musername" maxlength="12"></td></tr>
  13.  
  14. <tr><td class="list" align="left">Password:</td>
  15. <td class="list"><input type="password" name="mpass" maxlength="30"></td></tr>
  16.  
  17. <tr><td class="list" align="left">Verify Password: <br><i>(Retype your password)</i></td>
  18. <td class="list"><input type="password" name="mpwcheck" maxlength="30"></td></tr>
  19.  
  20. <tr><td class="list" align="left">Email: <br><i>(Please fill in a valid email)</i></td>
  21. <td class="list"><input type="text" name="memail" maxlength="50"></td></tr>
  22.  
  23. <tr><td class="list" align="left">Date of Birth: <br><i>Ex. 2010-10-23</i></td>
  24. <td class="list"><?php include_once("config/parseBirth.php"); echo showDate('month')."&nbsp;";
  25. echo showDate('day')."&nbsp;"; echo showDate('year'); ?></td></tr>
  26.  
  27. <tr><td class="list" align="left">Captcha: <br><i>(Retype the code in the image)</i></td>
  28. <td class="list"><img src="config/captcha.php" alt="Captcha" /><br />
  29. <input class="fieldlong" type="text" name="mcaptcha" />
  30. </td></tr>
  31.  
  32. <tr><td class="listtitle" align="left" colspan=2>
  33. <center><input type="image" src="images/button-register.png" class="submit" name="submit" value=" Register"/>
  34. <input type="hidden" name="register" value="1" /></td></tr></center>
  35.  
  36. </form>
  37. </table>
  38. </div>
  39. </center>
  40. </div>
  41. <?php
  42. } else {
  43. if (!isset($_POST["musername"]) OR
  44. !isset($_POST["mpass"]) OR
  45. !isset($_POST["mpwcheck"]) OR
  46. !isset($_POST["memail"]) OR
  47. !isset($_POST["mcaptcha"])) {
  48. die ("Error: Not all fields complete");
  49. }
  50.  
  51. include('config/init.php');
  52.  
  53. function checkEmail($mail) {
  54. if(preg_match("/^([.0-9a-z_-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,4})$/i", $mail)) {
  55. return TRUE;
  56. } else {
  57. return FALSE;
  58. }
  59. }
  60.  
  61. $username = mysql_real_escape_string($_POST["musername"]);
  62. $password = mysql_real_escape_string($_POST["mpass"]);
  63. $confirm_password = mysql_real_escape_string($_POST["mpwcheck"]);
  64. $email = mysql_real_escape_string($_POST["memail"]);
  65. $captcha = mysql_real_escape_string($_POST["mcaptcha"]);
  66. $birth = mysql_real_escape_string($_POST['year'])."-".mysql_real_escape_string($_POST['month'])."-".mysql_real_escape_string($_POST['day']);
  67.  
  68. $select_user_result = $database->query("SELECT `id` FROM `accounts` WHERE `name`='".$username."' OR `email`='".$email."' LIMIT 1");
  69. if ($database->rows() > 0) {
  70. $message = "This username or email is already used!";
  71. } else if ($password != $confirm_password) {
  72. $message = "Passwords didn't match!";
  73. } else if (strlen($password) < 4 || strlen($password) > 12) {
  74. $message = "Your password must be between 4-12 characters";
  75. } else if (strlen($username) < 4 || strlen($username) > 12) {
  76. $message = "Your username must be between 4-12 characters";
  77. } else if (!checkEmail($email)){
  78. $message = "You have filled in a wrong email address";
  79. } else if($captcha != $_SESSION['captcha_code']){
  80. $message = "The entered captcha is not valid!";
  81. } else {
  82. $insert_user_query = "INSERT INTO accounts (`name`, `password`, `email`, `birthday`) VALUES ('".
  83. $username."', '".hash("sha1", $password)."', '".$email."', '".$birth."')";
  84. $database->query($insert_user_query);
  85. $message = "<font color=\"green\">You have successfully registered to $servername !</font>";
  86. }
  87. ?>
  88. <div id="main">
  89. <center>
  90. <div class="h3">Registration</div>
  91. <div class="mainbox">
  92. <table cellspacing=1 cellpadding=5>
  93. <?php echo $message; ?>
  94. </table>
  95. </div>
  96. </div>
  97. <?php
  98. }
  99. ?>
Add Comment
Please, Sign In to add comment