title: The image "http://localhost/loginCaptcha.php" cannot be displayed because it contains errors
body: <p>I am trying to get a <code>CAPTCHA</code> to work. I have <code>PHP</code> files:</p>
  
  <p><code>loginCaptcha.php</code></p>
  
  <pre><code>&lt;?php
  session_start();
  header('Content-type: image/jpeg');
  
  $text = $_SESSION['secure'];
  $font_size = 30;
  
  $image_width = 200;
  $image_height = 40;
  
  $image = imagecreate($image_width, $image_height);
  imagecolorallocate($image, 255, 255, 255);
  $text_color = imagecolorallocate($image, 0, 0, 0);
  
  imagettftext($image, $font_size, 0, 15, 30, $text_color, 'font.ttf', $text);
  imagejpeg($image);
  ?&gt;
  </code></pre>
  
  <p><code>starter.php</code></p>
  
  <pre><code>&lt;?php
  session_start();
  $_SESSION['secure'] = rand(1000,9999);
  ?&gt;
  
  &lt;img src="loginCaptcha.php" /&gt;
  </code></pre>
  
  <p>When I run <code>loginCaptcha.php</code> the error comes from the title. When I run <code>starter.php</code> I get what looks like an undefined image. I checked and I have "gd" installed. I am using <code>xampp</code> so it came with it but I double checked anyway. </p>
  
  <p>I read other solutions but they did not really help me.</p>
  
  <p>Thanks.</p>