Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. register.php
  2. PHP Code:
  3. <?php
  4. include "functions.php";
  5.  
  6. if(isset($_POST['submit']))
  7. {
  8. $server = "PCNAMESQLEXPRESS";
  9. $user = "sa";
  10. $pass= "PASSWORT";
  11.  
  12. $username = strtolower(trim(htmlspecialchars(addslashes($_POST['username']))));
  13. $password = md5("kikugalanet".$_POST['password']);
  14.  
  15. ################################################## ###########
  16.  
  17. if(strlen($username) < 4 ||
  18. strlen($username) > 16)
  19. {
  20. die("Dein Benutzername ist zu kurz/lang .<br>Er muss zwischen <b><u>4 und 16</u></b> Zeichen lang sein .");
  21. }
  22.  
  23. if(strlen($_POST['password']) < 4 ||
  24. strlen($_POST['password']) > 16)
  25. {
  26. die("Dein Passwort ist zu kurz/lang .<br>Es muss zwischen <b><u>4 und 16</u></b> Zeichen lang sein .");
  27. }
  28.  
  29. ################################################## ###########
  30.  
  31. $conn = mssql_connect($server,$user,$pass);
  32.  
  33. if(!$conn)
  34. {
  35. die("Connection failed!<br>");
  36. }
  37.  
  38. $select = mssql_select_db("ACCOUNT_DBF",$conn);
  39.  
  40. if(!$select)
  41. {
  42. die("Can't select Database!<br>");
  43. }
  44.  
  45. ################################################## ###########
  46.  
  47. if(exist($username) != '0')
  48. {
  49. die ("Der Benutzername ".$username." wird schon benutzt .");
  50. }
  51.  
  52.  
  53. ################################################## ###########
  54.  
  55. $bind = mssql_init("createaccount",$conn);
  56.  
  57. if(!$bind)
  58. {
  59. die("Couldn't Bind Variables.<br>");
  60. }
  61.  
  62. $acc = $username;
  63. $pass = $password;
  64. $ipadress = $ip;
  65.  
  66. mssql_bind($bind, '@account' , $acc , SQLVARCHAR);
  67. mssql_bind($bind, '@password', $pass, SQLVARCHAR);
  68.  
  69. $execute = mssql_execute($bind);
  70.  
  71. if($execute)
  72. {
  73. echo 'Account wurde <font color="green">erfolgreich</font> erstellt !';
  74. }
  75. else
  76. {
  77. echo 'Account erstellung<font color="red">fehlgeschlagen</font> !';
  78. }
  79.  
  80. mssql_close($conn);
  81. }
  82. else
  83. {
  84.  
  85. ?>
  86. <center>
  87. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  88. <table>
  89. <tr>
  90. <td colspan="2" align ="center">
  91. <h3>Account erstellen</h3>
  92. </td>
  93. </tr>
  94. <tr>
  95. <td align ="right">
  96. Account :
  97. </td>
  98. <td>
  99. <input type="text" size="20" name="username" maxlength="15" />
  100. </td>
  101. <td>&nbsp;</td>
  102. </tr>
  103. <tr>
  104. <td align ="right">
  105. Passwort :
  106. </td>
  107. <td>
  108. <input type="password" size="20" name="password" maxlength="32" />
  109. </td>
  110.  
  111. </tr>
  112. <tr>
  113. <td colspan="2" align="center">
  114. <input type="submit" name="submit" value="Account erstellen" />
  115. </td>
  116. </tr>
  117. </table>
  118. </form>
  119. </center>
  120. <?php
  121. }
  122. ?>
  123. functions.php
  124. PHP Code:
  125. <?php
  126.  
  127. function exist($account){
  128. $sql = "SELECT * FROM ACCOUNT_TBL WHERE account='".$account."'";
  129. $result = mssql_query($sql);
  130. if(!$result) {
  131. die("MSSQL Error");
  132. }
  133. $check = mssql_num_rows($result);
  134. return $check;
  135. }
  136.  
  137. function existip($ip){
  138. $sql = "SELECT * FROM ACCOUNT_TBL_DETAIL WHERE ip='".$ip."'";
  139. $result = mssql_query($sql);
  140. if(!$result) {
  141. die("MSSQL Error");
  142. }
  143. $check = mssql_num_rows($result);
  144. return $check;
  145. }
  146.  
  147. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement