Guest User

Untitled

a guest
Jan 19th, 2019
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. Code: <font color="red" size="5"><b>Enter your username to exact capitals below and press submit then in game do /apply <thecode></font></b>
  2. <form action="apply.php" method="post">
  3. Minecraft Username: <input type="text" name="user" />
  4. <input type="submit" />
  5. </form>
  6.  
  7. <?PHP
  8. # If its loaded without form aka. if its in an iframe.
  9. if($_POST['user'] == "") {
  10. print '<font size="+4">Enter Username and press submit</font>';
  11. } else {
  12. # This is MySql information so fill it out
  13. $user_name = "die";
  14. $password = "die";
  15. $database = "die";
  16. $server = "die";
  17. # Connecting to the database
  18. $db_handle = mysql_connect($server, $user_name, $password);
  19. $db_found = mysql_select_db($database, $db_handle);
  20.  
  21. if ($db_found) {
  22.  
  23. $mysqli = new mysqli($server, $user_name, $password, $database);
  24. if(mysqli_connect_errno()) {
  25. echo "Connection Failed: " . mysqli_connect_errno();
  26. exit();
  27. }
  28.  
  29. if($stmt = $mysqli -> prepare("SELECT * FROM sqlapply Where playername=? VALUES (?)")) {
  30.  
  31. /* Bind parameters
  32. s - string, b - boolean, i - int, etc */
  33. $stmt -> bind_param("s", $_POST['user']);
  34.  
  35. /* Execute it */
  36. $stmt -> execute();
  37.  
  38. /* Bind results */
  39. $stmt -> bind_result($result);
  40.  
  41. /* Fetch the value */
  42. $stmt -> fetch();
  43.  
  44. /* Close statement */
  45. $stmt -> close();
  46. }
  47. /*$SQL = "SELECT * FROM sqlapply Where playername =". $_POST['user'];
  48. $result = mysql_query($SQL);
  49. */
  50. if ($result) {
  51. while ($db_field = mysql_fetch_assoc($result)) {
  52. print '<font size="+4">Your Apply Password is '.$db_field['applypassword'].'</font>';
  53. }
  54. }else {
  55. $pass = rand_string(5);
  56.  
  57.  
  58. $mysqli = new mysqli($server, $user_name, $password, $database);
  59.  
  60. if(mysqli_connect_errno()) {
  61. echo "Connection Failed: " . mysqli_connect_errno();
  62. exit();
  63. }
  64.  
  65. /* Create a prepared statement */
  66. if($stmt = $mysqli -> prepare("INSERT INTO sqlapply (playername, applypassword, time) VALUES (?, ?, ?)")) {
  67.  
  68. /* Bind parameters
  69. s - string, b - boolean, i - int, etc */
  70. $stmt -> bind_param("sss", $_POST['user'], $pass, time());
  71.  
  72. /* Execute it */
  73. $stmt -> execute();
  74.  
  75. /* Bind results
  76. $stmt -> bind_result($result);
  77. */
  78. /* Fetch the value */
  79. $stmt -> fetch();
  80.  
  81. /* Close statement */
  82. $stmt -> close();
  83. }
  84.  
  85. /* Close connection */
  86. $mysqli -> close();
  87.  
  88. # Printing the password
  89. print '<font size="+4">'.$_POST['user'].' Your Apply Password is '.$pass.'</font>';
  90. print '<p><font size="+4"> Valid for 1 hour</font></p>';
  91. print '<p><font size="+4">Make sure name is exact capitals</font></p>';
  92.  
  93. }
  94.  
  95. }else {
  96. print "Database NOT Found ";
  97. mysql_close($db_handle);
  98. }
  99. }
  100.  
  101. function rand_string( $length ) {
  102. # Characters random string can contain
  103. $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  104.  
  105. # Creating the string
  106. $size = strlen( $chars );
  107. for( $i = 0; $i < $length; $i++ ) {
  108. $str .= $chars[ rand( 0, $size - 1 ) ];
  109. }
  110.  
  111. return $str;
  112. }
  113.  
  114.  
  115. ?>
Add Comment
Please, Sign In to add comment