Jump to content

passing variable in animg src tag


Lassie

Recommended Posts

I want to build an image with text variables.

I can get the image OK but not the text, which I need to pass in an img tag from a form.

I have not posted the form  here as I know the post field is populated.

The static string shows overlayed on the image but not the variable string passed in the query string.

Any help appreciated.

My code is as follows:-

input form

<?php
if (isset($_POST['submitted'])) {
	if(isset($_POST['AuthorName'])){
	$str=($_POST['AuthorName']);


	?><img src="http://localhost:8888/test_upload/text-create2.php?str=' . $str . '"/><?php
	}

}
?>

 

The recieving script


<?php
$str2=$_GET['$str'];
$image = ImageCreateFromPNG("http://localhost:8888/wordpress_3/wp-content/plugins/Authors2/jackets/GDL.png");
$color = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$colorShadow = imagecolorallocate($image, 0x66, 0x66, 0x66);
$font = 'Tahoma.ttf';
$fontSize = "10";
$fontRotation = "0";
$str= "Successful Home Catering";


/* Shadow */
ImageTTFText($image, $fontSize, $fontRotation, 27, 22, $colorShadow, $font, $str );

/* Top Level */
ImageTTFText($image, $fontSize, $fontRotation, 25, 20, $color, $font, $str);

ImageTTFText($image, $fontSize, $fontRotation, 25, 100, $color, $font, $str2);

header("Content-Type: image/PNG");
ImagePng ($image);
imagedestroy($image);
?>

Link to comment
https://forums.phpfreaks.com/topic/227861-passing-variable-in-animg-src-tag/
Share on other sites

change

<?php
if (isset($_POST['submitted'])) {
if(isset($_POST['AuthorName'])){
$str=($_POST['AuthorName']);
?><img src="http://localhost:8888/test_upload/text-create2.php?str=' . $str . '"/><?php
}
}
?>

 

to this

 

<?php
if (isset($_POST['submitted'])) {
if(isset($_POST['AuthorName'])){
$str=($_POST['AuthorName']);
echo "<img src='http://localhost:8888/test_upload/text-create2.php?str=$str'/>";
}
}
?>

just echo it to the screen before

<?php
if (isset($_POST['submitted'])) {
if(isset($_POST['AuthorName'])){
$str=($_POST['AuthorName']);
echo "AuthorName=$str<br/>";
echo "<img src='http://localhost:8888/test_upload/text-create2.php?str=$str'/>";
}
}
?>

and the variable should be visable after the = sign when viewing

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.