Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('error_reporting', E_ALL);
- $username=""; //Your MySQL Username.
- $password=""; // Your MySQL Pass.
- $database=""; // Your MySQL database.
- $host=""; // Your MySQL host. This is "localhost" or the IP specified by your hosting company.
- $player_name=$_GET['player_name']; // This gets the player his name from the previous page.
- /* Next, we will make a connection to the mysql.
- If it can't connect, it'll print on the screen: Unable to select database. Be sure the databasename exists and online is. */
- mysql_connect($host,$username,$password); // Connection to the database.
- @mysql_select_db($database) or die( "Unable to select database. Be sure the databasename exists and online is."); //Selection of the database. If it can't read the database, it'll give an error.
- /* To protect MySQL injection. */
- $player_name = stripslashes($player_name);
- $player_name = mysql_real_escape_string($player_name);
- $query="SELECT * FROM `playerbase` WHERE `name` = '%s' LIMIT 1", 'pname'; // Gets all the information about the player.
- $result=mysql_query($query);
- $i=mysql_num_rows($result); // Here we are counting how many rows this result gives us.
- /* We will now put the player's information into variables so we can use them more easily. */
- /* DON'T FORGET: The names should be exact the same as in your mysql db.*/
- if ($i == 1) // If the user has been correct, then it'll give us 1 row. If its 1 row, then it'll proceed with the code.
- {
- $Playername=mysql_result($result,0,"name"); // Gets the username of the player and put it in the variable $Playername.
- $Money=mysql_result($result,0,"money"); // Gets the money of the player and put it in the variable $Money.
- $Score=mysql_result($result,0,"score"); // Gets the score of the player and put it in the variable $Score.
- $text_username = "$Playername"; // This gets the information about player name to be showed in the picture.
- $text_score = "$Score"; // Same as above ^^
- $text_money = "$Money"; // Same as above ^^
- // Establish image factors:
- $font_size = 18; // Font size is in pixels.
- $font_file = 'Tahoma.ttf'; // This is the path to your font file.
- // Create image:
- $image = imagecreatetruecolor(450, 110); // Create a truecolor image 450x110
- // Allocate text and background colors (RGB format):
- $bg_color = imagecolorallocate($image, 0, 0, 0);
- $text_color = imagecolorallocate($image,237,176,07);
- // Fill image:
- imagefill($image, 0, 0, $bg_color);
- // Bg IMG
- $bg_image = imagecreatefrompng("bg.png"); // Load PNG image
- imagecopy($image,$bg_image,0,0,0,0,450,110); // Then copy it into our image
- // Add TrueType text to image:
- imagettftext($image, $font_size, 0, 100, 60, $text_color, $font_file, "This is a test!");
- // Generate and send image to browser:
- header('Content-type: image/png');
- imagepng($image);
- // Destroy image in memory to free-up resources:
- imagedestroy($image);
- } else echo('Username is not in our database. Please try again.'); // If the username doesn't exist (so the row is 0) then it'll give en error.
- mysql_close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement