Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

PDO signature
Friday, May 18th, 2012 at 10:07:29am MDT 

  1. <?php
  2. //error_reporting(0);//Un-comment when you have no errors or done debugging
  3.  
  4. //PDO mysql connection initialization
  5. $pdo = new PDO('mysql:host=hostname;dbname=somedb','username','password');
  6.  
  7. //Lets check if we have a name set
  8. if(!isset($_GET['name'])){
  9.         print "No users found";
  10. }
  11. else{
  12.         // XSS clean up
  13.         $var = strip_tags($_GET['name']);
  14.  
  15.         $result = $pdo->prepare("SELECT * FROM yourtable WHERE username = :name LIMIT 1");//lets prepare the query
  16.  
  17.         $result->bindParam(':name', $var); //Lets binds the parameter
  18.  
  19.         $result->execute();//Lets push the query forward to MySQL server
  20.  
  21.         if($result->fetchColumn() > 0)//Lets check row here!
  22.         {
  23.                 header('Content-Type: image/jpeg');
  24.                 $image = imagecreatefrompng("linktoyour.png") or die("Oops image could not be parsed");
  25.                 $text = imagecolorallocate($image, 255,255,255); //Lets set text color here and share the code with image parsed.
  26.                 $font = 'linktoyourfont.ttf';//Linux accepts only .ttf format.
  27.                 imagettftext($image, 12, 0, X co - ordinate, Y co - ordinate, $text, $font, $yourfetchedparameterfromserver);
  28.                 /* after adding all the parameters you want here :)*/
  29.  
  30.                 imagepng($im); // Lets create the image from memory
  31.                 imagedestroy($im);// Lets display the image and destroy it from memory so it serves live.
  32.         }
  33.         else{
  34.                 print "Error!";
  35.         }
  36. }
  37.  
  38. ?>

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right