title: Can't get GD image to display
body: <p>my code:
  save this file as captcha.php</p>
  
  <pre><code>    &lt;?php
  ob_start();
  session_start();
  if(!isset($_POST['submit'])){
      echo "&lt;form method=\"post\" action=\"captcha.php\"&gt;\n";
      echo "&lt;table border=\"0\" cellspacing=\"3\" cellpadding=\"3\"&gt;\n";
      echo "&lt;tr&gt;&lt;td&gt;Type The Letters You See Below Into the Box&lt;/td&gt;&lt;/tr&gt;\n";
      echo "&lt;tr&gt;&lt;td align=\"center\"&gt;&lt;img src=\"image.php\"&gt;&lt;/td&gt;&lt;/tr&gt;\n";
      echo "&lt;tr&gt;&lt;td align=\"center\"&gt;&lt;input type=\"text\" name=\"image\"&gt;&lt;/td&gt;&lt;/tr&gt;\n";
      echo "&lt;tr&gt;&lt;td align=\"center\"&gt;&lt;input type=\"submit\" name=\"submit\" value=\"Check CAPTCHA\"&gt;&lt;/td&gt;&lt;/tr&gt;\n";
      echo "&lt;/table&gt;&lt;/form&gt;\n";
  }else {
      $image = $_POST['image'];
      if ($image == $_SESSION['string'])
      {
          echo "&lt;b&gt;Great success!&lt;/b&gt;\n";
      }
      else 
      {
          echo "&lt;em&gt;Failure!&lt;/em&gt;\n";
      }
  }
  ob_end_flush();
  ?&gt; 
  </code></pre>
  
  <p>save this file as image.php</p>
  
  <pre><code>&lt;?php
  
  session_start();
  $img = imagecreatetruecolor(118,80);
  
  $white = imagecolorallocate($img, 255, 255, 255);
  $black = imagecolorallocate($img, 0, 0, 0);
  $red = imagecolorallocate($img, 255, 0, 0);
  $grey = imagecolorallocate($img,150, 150, 150);
  $pink = imagecolorallocate($img, 200, 0, 150);
  $yellow = imagecolorallocate($img, 255, 246, 0);
  
  function randomString($length){
      $chars = "abcdefghijkmnopqrstuvwxyz023456789";
      srand((double)microtime()*1000000);
      $str = "";
      $i = 0;
  
          while($i &lt;= $length){
              $num = rand() % 33;
              $tmp = substr($chars, $num, 1);
              $str = $str . $tmp;
              $i++;
          }
      return $str;
  }
  
  for($i=1;$i&lt;=rand(1,5);$i++){
      $color = (rand(1,2) == 1) ? $pink : $red;
      imageline($img,rand(6,90),rand(6,40), rand(6,90)+6,rand(6,40)+6, $color);
  }
  
  imagefill($img, 0, 0, $yellow);
  
  $string = randomString(rand(4,6));
  $_SESSION['string'] = $string;
  
  imagettftext($img, 20, 10, 10, 52, $black, "calibri.ttf", $string);
  imagettftext($img, 20, 10, 12, 53, $grey, "calibri.ttf", $string);
  
  header("Content-type: image/png");
  imagepng($img);
  imagedestroy($img);
  
  ?&gt;
  </code></pre>
  
  <p>go to this address <a href="http://www.cufonfonts.com/en/font/12048/calibri" rel="nofollow">http://www.cufonfonts.com/en/font/12048/calibri</a> and download the font and save it in the same root folder as the to .php files we just created.</p>
  
  <p>NOTE!! THIS WILL WORK ON LOCALHOST BUT IM HAVING A PROBLEM WITH THE image.php file SHOWING UP LIKE THIS -> ����JFIF��>CREATOR: gd-jpeg v1.0 (using IJG JPEG v90), default quality ��C    $.' ",#(7),01444'9=82&lt;.342��C  2!!22222222222222222222222222222222222222222222222222��x"�����}!1AQa"q2���#B��R��$3br� . </p>
  
  <p>THIS ONLY HAPPENS WHEN I TRY AND ADD IT TO THE CMS I CREATED. ALL I NEED TO KNOW IS WHY THIS IS HAPPENING I HAVE A FEELING ITS GOT SOMETHING TO DO WITH "header("Content-type: image/png");" although i could be way wrong. please help me. by the way im am trying to add a email form and have the captcha evaluate it </p>
  
  <p>this is the form i am trying to insert the code into:
  you can save it as form.php</p>
  
  <pre><code>&lt;?php
  $query = mysql_query("SELECT * FROM forms where id = '$formid'");
  
  echo '&lt;h2&gt;'.mysql_result($query, 0, "title").'&lt;/h2&gt;';
  
  if(mysql_result($query, 0, "description") != "") {
      echo '&lt;p&gt;'.mysql_result($query, 0, "description").'&lt;/p&gt;';
  } 
  error_reporting(E_ERROR);
  
  ?&gt;
  &lt;form action="plugins/form_send.php" method="post" enctype="multipart/form-data" class="ajax" name="formplugin" id="form_&lt;?php echo $formid; ?&gt;"&gt;
  &lt;input name="formid" id="formid" type="hidden" value="&lt;?php echo $formid; ?&gt;" /&gt;
    &lt;p&gt;&lt;span class="required"&gt;*&lt;/span&gt; = required fields.&lt;/p&gt;
    &lt;table border="0" cellspacing="5" cellpadding="5"&gt;
      &lt;?php 
      $field_labels_col = mysql_result($query, 0, "field_label");
      $field_labels = array();
      $field_labels =(explode('|', $field_labels_col));
  
      $field_types_col = mysql_result($query, 0, "field_type");
      $field_types = array();
      $field_types =(explode('|', $field_types_col));
  
      $field_option1_col = mysql_result($query, 0, "field_option1");
      $field_option1 = array();
      $field_option1 =(explode('|', $field_option1_col));
  
      $field_option2_col = mysql_result($query, 0, "field_option2");
      $field_option2 = array();
      $field_option2 =(explode('|', $field_option2_col));
  
      $field_validtype_col = mysql_result($query, 0, "field_validtype");
      $field_validtype = array();
      $field_validtype =(explode('|', $field_validtype_col));
  
      $i = 0;
      while (array_key_exists($i, $field_labels))
      {
      if(!isset($title)) { $title = ''; }
      if($title != $field_labels[$i]) {
  
      if(isset($field_labels[$i])) { $title = $field_labels[$i]; }
      if(isset($title)) { $stripped = urlify($title); }
      if(isset($field_types[$i])) { $type = $field_types[$i]; }
      if(isset($field_option1[$i])) { $option1 = $field_option1[$i]; }
      if(isset($field_option2[$i])) { $option2 = $field_option2[$i]; }
      if(isset($field_validtype[$i])) { $valid = $field_validtype[$i]; }
  
      echo '&lt;tr&gt;';
        echo '&lt;td align="left" valign="top"&gt;'.$title.'&lt;/td&gt;';
        echo '&lt;td align="left" valign="top"&gt;';
  
          // -- INPUT FIELDS --
          if($type == "input") {
              echo '&lt;input name="'.$stripped.'" type="text" id="'.$stripped.'" size="'.$option1.'" maxlength="'.$option2.'" /&gt;';
              if($valid != '') { echo '&lt;span class="required"&gt;*&lt;/span&gt;'; }
          }
  
          // -- TEXT AREAS --
          if($type == "textarea") {
              echo '&lt;textarea name="'.$stripped.'" cols="'.$option1.'" rows="size="'.$option2.'"" id="'.$stripped.'"&gt;&lt;/textarea&gt;';
          }
  
          // -- DROP DOWNS --
          if($type == "dropdown") {
              echo '&lt;select name="'.$stripped.'" id="'.$stripped.'"&gt;';
                  $l = 0;
                  while (array_key_exists($l, $field_labels))
                  {
                  $thisoption = $field_option1[$l];
                  $thistitle = $field_labels[$l];
                  if($thistitle == $title) {
                  echo '&lt;option value="'.$thisoption.'"&gt;'.$thisoption.'&lt;/option&gt;';
                  }
                  $l++;
                  }
              echo'&lt;/select&gt;';
          }
  
          // -- RADIO BUTTONS --
          if($type == "radiobutton") {
              $l = 0;
              while (array_key_exists($l, $field_labels))
              {
              $thisoption = $field_option1[$l];
              $thistitle = $field_labels[$l];
              $thisstripped = urlify($field_labels[$l]);
              if($thistitle == $title) {
                echo '&lt;label&gt;&lt;input type="radio" name="'.$thistitle.'" id="'.$thisstripped.'" value="'.$option1.'"&gt;'.$thisoption.'&lt;/label&gt;&lt;br /&gt;';
              }
              $l++;
              }
          }
  
          // -- SIMPLE YES / NO --
          if($type == "yesno") {
              echo '&lt;label&gt;&lt;input type="radio" name="'.$stripped.'" id="'.$stripped.'" value="Yes"&gt;Yes&lt;/label&gt;';
              echo '&lt;label&gt;&lt;input type="radio" name="'.$stripped.'" id="'.$stripped.'" value="No"&gt;No&lt;/label&gt;';
          }
  
          // -- FILE UPLOADS --
          if($type == "fileupload") {
              echo '&lt;input type="file" name="'.$stripped.'" id="'.$stripped.'" size="10"&gt; (2mb limit)';
          }
  
        echo '&lt;/td&gt;';
      echo '&lt;/tr&gt;';
      }
      $i++;
      }
  ?&gt;
      &lt;tr id="comment-div"&gt;&lt;td colspan="2"&gt;&lt;input name="user-comment" size="3" value="" /&gt;&lt;/td&gt;&lt;/tr&gt;
  
      &lt;tr&gt;
          &lt;td colspan="2"&gt;
              &lt;?php if(mysql_result($query, 0, "submit_text") != "") { ?&gt;
                  &lt;p&gt;&lt;br /&gt;&lt;?php echo mysql_result($query, 0, "submit_text"); ?&gt;&lt;/p&gt;
              &lt;?php } ?&gt;
              &lt;div id="result"&gt;&lt;strong&gt;Loading... please wait.&lt;/strong&gt;&lt;/div&gt;
              &lt;!-- &lt;input type="submit" name="button" id="button" value="&lt;?php echo mysql_result($query, 0, "submit_button"); ?&gt;" /&gt; --&gt;
  
  
  
          &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>