Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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>
- <form action="apply.php" method="post">
- Minecraft Username: <input type="text" name="user" />
- <input type="submit" />
- </form>
- <?PHP
- # If its loaded without form aka. if its in an iframe.
- if($_POST['user'] == "") {
- print '<font size="+4">Enter Username and press submit</font>';
- } else {
- # This is MySql information so fill it out
- $user_name = "die";
- $password = "die";
- $database = "die";
- $server = "die";
- # Connecting to the database
- $db_handle = mysql_connect($server, $user_name, $password);
- $db_found = mysql_select_db($database, $db_handle);
- if ($db_found) {
- $mysqli = new mysqli($server, $user_name, $password, $database);
- if(mysqli_connect_errno()) {
- echo "Connection Failed: " . mysqli_connect_errno();
- exit();
- }
- if($stmt = $mysqli -> prepare("SELECT * FROM sqlapply Where playername=? VALUES (?)")) {
- /* Bind parameters
- s - string, b - boolean, i - int, etc */
- $stmt -> bind_param("s", $_POST['user']);
- /* Execute it */
- $stmt -> execute();
- /* Bind results */
- $stmt -> bind_result($result);
- /* Fetch the value */
- $stmt -> fetch();
- /* Close statement */
- $stmt -> close();
- }
- /*$SQL = "SELECT * FROM sqlapply Where playername =". $_POST['user'];
- $result = mysql_query($SQL);
- */
- if ($result) {
- while ($db_field = mysql_fetch_assoc($result)) {
- print '<font size="+4">Your Apply Password is '.$db_field['applypassword'].'</font>';
- }
- }else {
- $pass = rand_string(5);
- $mysqli = new mysqli($server, $user_name, $password, $database);
- if(mysqli_connect_errno()) {
- echo "Connection Failed: " . mysqli_connect_errno();
- exit();
- }
- /* Create a prepared statement */
- if($stmt = $mysqli -> prepare("INSERT INTO sqlapply (playername, applypassword, time) VALUES (?, ?, ?)")) {
- /* Bind parameters
- s - string, b - boolean, i - int, etc */
- $stmt -> bind_param("sss", $_POST['user'], $pass, time());
- /* Execute it */
- $stmt -> execute();
- /* Bind results
- $stmt -> bind_result($result);
- */
- /* Fetch the value */
- $stmt -> fetch();
- /* Close statement */
- $stmt -> close();
- }
- /* Close connection */
- $mysqli -> close();
- # Printing the password
- print '<font size="+4">'.$_POST['user'].' Your Apply Password is '.$pass.'</font>';
- print '<p><font size="+4"> Valid for 1 hour</font></p>';
- print '<p><font size="+4">Make sure name is exact capitals</font></p>';
- }
- }else {
- print "Database NOT Found ";
- mysql_close($db_handle);
- }
- }
- function rand_string( $length ) {
- # Characters random string can contain
- $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- # Creating the string
- $size = strlen( $chars );
- for( $i = 0; $i < $length; $i++ ) {
- $str .= $chars[ rand( 0, $size - 1 ) ];
- }
- return $str;
- }
- ?>
Add Comment
Please, Sign In to add comment