What are some common mistakes that beginners make when trying to output form results as images in PHP?

One common mistake beginners make when trying to output form results as images in PHP is not setting the correct content type header before outputting the image data. This can result in the image not displaying correctly or at all. To solve this issue, make sure to set the content type header to "image/jpeg" or "image/png" before outputting the image data.

<?php
// Set content type header
header('Content-Type: image/jpeg');

// Output image data
$imageData = file_get_contents('image.jpg');
echo $imageData;
?>