I am trying to write a script where users will be able to type text on the form and those texts will be printed on image.
I have done this with PHP, and here is my PHP code:
<?php
$user = $_POST["user"];
$imageSource = "cake.jpg";
$makeImage = $_POST["user"] . ".jpg";
$image = imagecreatefromjpeg($imageSource);
$font = "sans.ttf";
$color = imagecolorallocate($image, 0,0,0);
$x = 100;
$y = 200;
$destination = "upload/".$makeImage;
imagettftext ($image, 100,0,$x,$y, $color, $font, $user);
imagejpeg($image, 'upload/'. $makeImage);
?>
How do I refresh the existing image of the page with the new one created by my PHP script? I have heard, it's done by ajax. If someone can write the code, I will appreciate it very much.
How do I keep the same PHP code and adjust the text position for different images on the webpage? I think this one is also done in Ajax.