Ok, let's assume your form uses POST method and has two text inputs: x and y. In a script, to which action points, you can have your image:
<img src="image.php?x=<?php echo $_POST['x'];?>&y=<?php echo $_POST['y'];?>&src=<?php echo $bg_image;?>">
In $bg_image you can store the path to image, where you want to draw.
And now, to write image.php you should read about images in php manual: http://pl.php.net/manual/en/ref.image.php
Pseudocode would look like
<?php
//this is image.php
//send headers for appropriate image
header("...");
//create image resource from file, for example for jpg
$im = ImageCreateFromJPEG($_GET["src"]);
//now draw what you want, depending on $_GET['x'] and "y" using $im
//then output image
ImageJPEG($im);
//then destroy resource
ImageDestroy($im);
?>
Remember, that this is just a sketch of what you should do - it lacks error checking and input data validating for example.
More details and examples of how to use image functions - in php manual