Lassie Posted February 16, 2011 Share Posted February 16, 2011 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); ?> Quote Link to comment Share on other sites More sharing options...
dragon_sa Posted February 16, 2011 Share Posted February 16, 2011 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'/>"; } } ?> Quote Link to comment Share on other sites More sharing options...
Lassie Posted February 16, 2011 Author Share Posted February 16, 2011 Thanks for your reply. This gives a very small broken image I'm afraid. Is ther e a way to check the variable is being passed? Quote Link to comment Share on other sites More sharing options...
dragon_sa Posted February 16, 2011 Share Posted February 16, 2011 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 Quote Link to comment Share on other sites More sharing options...
Lassie Posted February 16, 2011 Author Share Posted February 16, 2011 Yes, Sorry I meant in the recieving script. Quote Link to comment Share on other sites More sharing options...
dragon_sa Posted February 16, 2011 Share Posted February 16, 2011 this $str2=$_GET['$str']; should be $str2=$_GET['str']; Quote Link to comment Share on other sites More sharing options...
Lassie Posted February 16, 2011 Author Share Posted February 16, 2011 Thank you. That works. I will now develop this a little bit with some more vars and I also need to save the image. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.