Q:

Display GD image on another page

i want to add some text to an image via a form..
I do not have any experience with GD, but i've gotten it to add the text, and show an image with the header content type... The problem with that is, i can only display that, and that only on the page, no other content...
If i could even get it to return from an ajax call that'd be awesome, even though i've not worked with ajax either..
Code:
index.php:::::::
elseif($_GET['p'] == "Images"){
    ?>
    <form action="test.php" method="post">
        <input type="text" name="name" value="">
        <input type="submit" name="submit" value="submit" >
    </form>

    <?php
    if(!isset($_GET['display'])) $_GET['display'] = "false";    
    if($_GET['display'] == "true"){
        echo "<img src='test.php' />";
    }   
}

test.php:::::
$font = "Images/Pokedex.TTF"; // full path to your font file
$text = $_POST['name'];

$image = imagecreatefrompng("Images/1.png"); 
$color = imagecolorallocate($image, 0, 0, 0);

imagettftext($image, 12, 0, 20, 235, $color, $font, $text);

// define content-type header
header("Content-type: image/png");
// output image as a png image
imagepng($image);
//header("Location:index.php?p=Images&display=true");
// and free the memory 
imagedestroy($image);  

A:

You may include <img src='test.php' /> to any your html code fore gettingphp generated image on it. You may use get param to pass test for image, like this:
<!-- Any HTML code (my be generated by PHP -->
<img src='test.php?name=My+Text' />

For test.php:
//Replace $text = $_POST['name'];
$text = $_GET['name'];

