Guest User

Untitled

a guest
Oct 28th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. <?php
  2. /* Copyright 2011 Aaron Roderigues */
  3. function doesUsernameExist($name){
  4. $exit = FALSE;
  5. $result = @mssql_query("SELECT * FROM dbo.ACCOUNT_TBL WHERE account='$name'");
  6. if(mssql_num_rows($result) != 0){
  7. $exit = TRUE;
  8. }
  9. return $exit;
  10. }
  11. function cl($info){
  12. return strtolower(preg_replace("|[^\w]|", "", $info));
  13. }
  14.  
  15.  
  16. if(isset($_POST['submit'])){
  17. /* Start editing */
  18. $salt = "kikugalanet";
  19. $secure_email = $_POST['email'];
  20. $cash = 0;
  21. $link = @mssql_connect("PRiiME", "sa", "Hallo!123") or die ("Server is down!");
  22. $db = @mssql_select_db('ACCOUNT_DBF') or die ("Accout table is missing!");
  23. /* */
  24. $username = cl($_POST['username']);
  25. $password = cl($_POST['password']);
  26. $password_hashed = md5($salt.$password);
  27.  
  28.  
  29. if(empty($username) || strlen($username) > 15){
  30. echo "Problem with your username.";
  31. exit();
  32. }
  33. else if(empty($password) || strlen($password) > 36){
  34. echo "Problem with your password.";
  35. exit();
  36. }
  37. else if(doesUsernameExist($username)){
  38. echo "Username already exists.";
  39. exit();
  40. }
  41. /* Passed everything, so lets create the account. */
  42. $stmt = mssql_init('usp_CreateNewAccount', $link);
  43. mssql_bind($stmt, '@account', $username, SQLVARCHAR, false, false, 32);
  44. mssql_bind($stmt, '@pw', $password_hashed, SQLVARCHAR, false, false, 32);
  45. mssql_bind($stmt, '@cash', $cash, SQLINT1, false, false);
  46. mssql_bind($stmt, '@email', $secure_email, SQLVARCHAR, false, false, 100);
  47. mssql_execute($stmt) or die ("Something is wrong on the execution.");
  48. mssql_free_statement($stmt);
  49. echo "User account created for: ".$username;
  50. mssql_close($link);
  51. exit();
  52. }
  53. ?>
  54. <!DOCTYPE html>
  55. <html>
  56. <body>
  57. <div>
  58. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
  59. <table>
  60. <tr>
  61. <td>Username:</td>
  62. <td><input size="20" name="username" maxlength="15" type="text" /></td>
  63. <td>(A-Z, a-z, 1-9)</td>
  64. </tr>
  65. <tr>
  66. <td>Password:</td>
  67. <td><input size="20" name="password" maxlength="35" type="password" /></td>
  68. <td>(A-Z, a-z, 1-9)</td>
  69. </tr>
  70. <tr>
  71. <td>Email:</td>
  72. <td><input size="20" name="email" maxlength="255" type="text" /></td>
  73. </tr>
  74. </table>
  75. <input type="submit" name="submit" value="register" />
  76. </form>
  77. </div>
  78. </body>
  79. </html>
Add Comment
Please, Sign In to add comment