The imagejpeg (and its cousins) function sends binary straight to the output buffer (the web browser). That won't work unless you tell the web browser that the content you're giving it is an image by setting the Content-Type header.
In your case, you're sending the web browser an HTML file, so you have to write your freshly rotated image to the hard disk first. Then you can refer to it in an IMG tag in your HTML. The key is that PHP must have write privileges on the directory you want to write your rotated image to, and that directory must be accessible from your website's document root.
Here's an example that might help...
$image_file = "italy.jpg";
$images_root = $_SERVER['DOCUMENT_ROOT'] . "/photos";
$image_path = $images_root . "/" . $image_file;
exit("Can't find image at " . $image_path);
$rotate = $_GET['rotate'];
// Pass degrees to rotate the image on the URL as ?rotate=
if (!empty($rotate) && is_numeric($rotate) && ($rotate >= 0 && $rotate <= 360))
$image_handle = imagecreatefromjpeg($image_path);
exit("GD could not load image into memory: " . $image_path);
// Rotate the image -- remember this is done in memory
$rotated_image_handle = imagerotate($image_handle, $rotate, 0);
// Now we need to write the rotated image out to the disk
// First, we need a file name to write to and we must be able
// to write to the $images_root directory
$rotated_image_path = tempnam($images_root, "") . ".jpg";
// Now, write the image to disk
$success = imagejpeg($rotated_image_handle, $rotated_image_path, 80);
exit("GD could not write rotated image to disk");
// Now we can refer to the new file we wrote to disk in our HTML
echo "<img src=\"photos/".basename($rotated_image_path)."\" />";
echo "<img src=\"photos/".$image_file."\" />";