Page 1 of 1

Dynamic Signature.

Posted: Sat May 02, 2009 7:36 am
by SniperTowers
I currently have this code:

Code: Select all

<?php
session_start();
require ("connect.php");
require ("func.php");
    
    $result = mysql_query("SELECT * FROM users WHERE id='$id'");
    $getbalance = mysql_fetch_array($result);
    $balance = $getbalance['balance'];
    
$v = array(
"Hello...",
 
);
 
$message = $v[rand(0, sizeof($v)-1)];
header ("Content-type: image/png");
$im = imagecreatefrompng("background.png");
$img_handle = ImageCreate (300, 100) or die ("Cannot Create image");
$back_color = ImageColorAllocate ($img_handle, 255, 255, 255);
imagecolortransparent ($img_handle, $back_color);
$color_1 = ImageColorAllocate ($img_handle, 255, 102, 51);
$color_2 = ImageColorAllocate ($img_handle, 1, 1, 1);
$color_3 = ImageColorAllocate ($img_handle, 51, 102, 255);
ImageLine($img_handle, 0, 1, 250, 1, $color_2);
ImageString ($im, 40, 0,2, "Username: ", $color_1);
ImageString ($im, 40, 80,2, $username, $color_1);
ImageString ($im, 40, 0,12, "Balance: ", $color_1);
ImageString ($im, 40, 80,12, $balance, $color_1);
ImageString ($img_handle, 2, 0,22, "Euro-time guild on Crushbone", $color_1);
ImageString ($img_handle, 31, 0,35, "Loading Please Wait...", $color_2);
ImageString ($img_handle, 0, 0, 50, $message, $color_3);
ImagePng ($im);
?>
But it only displays $username and $balance if you are logged in. How could I make it so that it generates a new sig with a users $username and $balance even when they are logged out.

Re: Dynamic Signature.

Posted: Sat May 02, 2009 7:30 pm
by McInfo
Send the ID in the URL.

Code: Select all

<img src="sig.php?id=42" alt="" />
Access it with $_GET['id']. Sanitize it before you use it in your query.

Code: Select all

// Replaces any character that is not a digit with an empty string
$id = preg_replace('/[^0-9]/', '', $_GET['id']);
Edit: This post was recovered from search engine cache.