Hi everyone,

I am successfully creating an image with php, but I want to make it hyperlinked. But I cant do it.

Here is my script:

http://www.forumistan.net/7tepe/olus.php?site=www.bodrumlife.com


PHP Code:

<?php  
header("Content-type: image/png");  
$yaziyaz = "Alexa: 3,493,231";  
$yaziyaz1 = "Pagerank: 3";  
$string = $yaziyaz;  
$string1 = $yaziyaz1;  
$im = imagecreatefrompng("resim.png");  
$orange = imagecolorallocate($im, 94, 94, 94);  
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;  
$px1 = (imagesx($im) - 11 * strlen($string1)) / 2;  
imagestring($im, 2, $px, 2, $string, $orange);  
imagestring($im, 2, $px1, 13, $string1, $orange);  
imagepng($im);  
imagedestroy($im);  
?>

--------------------------------------

I tried this but I got "headers already sent" errors.

<?php 
echo "<a href=http://www.forumistan.net>";
header("Content-type: image/png"); 
$yaziyaz = "Alexa: 3,493,231"; 
$yaziyaz1 = "Pagerank: 3"; 
$string = $yaziyaz; 
$string1 = $yaziyaz1; 
$im = imagecreatefrompng("resim.png"); 
$orange = imagecolorallocate($im, 94, 94, 94); 
$px = (imagesx($im) - 7.5 * strlen($string)) / 2; 
$px1 = (imagesx($im) - 11 * strlen($string1)) / 2; 
imagestring($im, 2, $px, 2, $string, $orange); 
imagestring($im, 2, $px1, 13, $string1, $orange); 
imagepng($im); 
imagedestroy($im); 
echo "</a>";
?>

___________

And I forgot to say that, I dont want to use html to hyperlink like this: <a href=#>http://www.forumistan.net/7tepe/olus.php?site=www.bodrumlife.com</a> I want to make it hyperlinked it in the php file...

Recommended Answers

All 2 Replies

???

1) outsource the creation of the image. Make a image.php where you put your code into.
2) make a new file, write a html-hyperlink, and then use <img src="image.php">

should work.

You cannot output an image after having used html-syntax. So image-creation has always to be outsourced.

hjhhjgj

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.