Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.69 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>FnF-Pk Account Register</title>
  4. <style>
  5. body {
  6. color: #003300;
  7. font-family: Verdana, Arial, Serif;
  8. font-size: 10pt;
  9. }
  10. input {
  11. border: 1px solid #003300;
  12. color: #003300;
  13. background: #DDDDDD;
  14. font-family: Verdana, Arial, Serif;
  15. font-size: 10pt;
  16. }
  17. tr {
  18. font-size: 10pt;
  19. }
  20. a:link {
  21. text-decoration: none;
  22. color: #003300;
  23. }
  24. a:visited {
  25. text-decoration: none;
  26. color: #003300;
  27. }
  28. a:active {
  29. text-decoration: none;
  30. color: #003300;
  31. }
  32. a:hover {
  33. text-decoration: none;
  34. color: #FF6600;
  35. }
  36. </style>
  37. </head>
  38. <body>
  39. <div align="center">
  40. <?php
  41. $mysql_user = "phost145282";
  42. $mysql_pass = "leftbehind";
  43. $mysql_database = "phost145282";
  44. $mysql_host = "localhost";
  45. ?>
  46. <FORM METHOD=POST ACTION="<?php echo $_SERVER['PHP_SELF']; ?>?act=register">
  47. <table cellspacing=0 border=0>
  48. <tr>
  49. <td colspan=2 style="border: 1px solid #003300; background: #DDDDDD;"><CENTER><A HREF="index.php">FnF-Pk Account Register</A></CENTER></td>
  50. </tr>
  51. <tr>
  52. <td style="border-left: 1px solid #003300">&nbsp;User:</td>
  53. <td style="border-right: 1px solid #003300"><INPUT TYPE="text" NAME="login"&nbsp;></td>
  54. </tr>
  55. <tr>
  56. <td style="border-left: 1px solid #003300">&nbsp;Password:</td>
  57. <td style="border-right: 1px solid #003300"><INPUT TYPE="password" NAME="senha1">&nbsp;</td>
  58. </tr>
  59. <tr>
  60. <td style="border-left: 1px solid #003300">&nbsp;Retype Password:&nbsp;</td>
  61. <td style="border-right: 1px solid #003300"><INPUT TYPE="password" NAME="senha2">&nbsp;</td>
  62. </tr>
  63. <tr>
  64. <td style="border-left: 1px solid #003300">&nbsp;Email:</td>
  65. <td style="border-right: 1px solid #003300"><INPUT TYPE="text" NAME="email">&nbsp;</td>
  66. </tr>
  67. <tr>
  68. <td style="border: 1px solid #003300; border-top: 0px;" colspan=2><CENTER><INPUT NAME="Register" VALUE="Register" TYPE="submit"></CENTER></td>
  69. </tr>
  70. </table>
  71. </FORM>
  72. <?php
  73.  
  74. if ($_GET['act'] == 'register')
  75. {
  76. $conn = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
  77. mysql_select_db($mysql_database);
  78. $user = anti_injection($_POST['login']);
  79. $pass1 = anti_injection($_POST['senha1']);
  80. $pass2 = anti_injection($_POST['senha2']);
  81. $email = anti_injection($_POST['email']);
  82. if (valida(Array($user,$pass1,$pass2,$email)) == true)
  83. {
  84. if ($pass1 == $pass2)
  85. {
  86. if (ereg("([0-9,a-z,A-Z])", $user))
  87. {
  88. if (ereg("^([0-9,a-z,A-Z]+)([.,_]([0-9,a-z,A-Z]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $email))
  89. {
  90. $query = mysql_query("SELECT * FROM accounts WHERE login='$user'");
  91. $num_rows = mysql_num_rows($query);
  92. if ($num_rows == 0)
  93. {
  94. $query = mysql_query("SELECT * FROM accounts WHERE email='$email'");
  95. $num_rows = mysql_num_rows($query);
  96. if ($num_rows == 0)
  97. {
  98. $query = mysql_query("INSERT INTO contas (login, password, email, status) VALUES ('$user','$pass1','$email','0')");
  99. if (!$query)
  100. {
  101. echo ":: Error on trying to register account ::";
  102. }
  103. else
  104. {
  105. echo ":: Account added with sucess ::";
  106. }
  107. }
  108. else
  109. {
  110. echo ":: Email is already exist in database ::";
  111. }
  112. }
  113. else
  114. {
  115. echo ":: User is already exist in database ::";
  116. }
  117. }
  118. else
  119. {
  120. echo ":: Invalid email type ::";
  121. }
  122. }
  123. else
  124. {
  125. echo ":: Use only numbers(0-9) and letters(a-z) ::";
  126. }
  127. }
  128. else
  129. {
  130. echo ":: The password is not equal ::";
  131. }
  132. }
  133. }
  134.  
  135. // Função Anti Injection
  136.  
  137. function anti_injection($sql)
  138. {
  139. $sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"),"",$sql);
  140. $sql = trim($sql);
  141. $sql = strip_tags($sql);
  142. $sql = addslashes($sql);
  143. return $sql;
  144. }
  145.  
  146. // Verificar Campos Vazios
  147.  
  148. function valida($campos){
  149. foreach($campos as $c){
  150. if(empty($c)){
  151. echo ":: Write all fields ::<br>";
  152. return false;
  153. }else{
  154. return true;
  155. }
  156. }
  157. }
  158. ?>
  159. </div>
  160. </body>
  161. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement