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
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'/>";
}
}
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.