Non riesco a far funzionare un modulo di captcha

io ho questa pagina col form:

Codice PHP:
<h2>Contattaci</h2>           
<form action="ok.php" method="post" name="frm_message" id="frm_message" onsubmit="MM_validateForm('emailAddress','','RisEmail','name','','R','subject','','R','body','','R');return document.MM_returnValue">       
<table width="50%" height="243" border="0" align="left" cellpadding="3" cellspacing="0" bgcolor="#eeeeee">         <tr>           <td nowrap="nowrap"><strong class="bodyText">Il tuo indirizzo email*[/b] </td>           
<td><input name="emailAddress" type="text" id="emailAddress" size="30" /></td>         </tr>         <tr>           
<td><strong class="bodyText">Il tuo nome [/b]</td>           
<td><input name="name" type="text" id="name" size="30" /></td>         </tr>         <tr>           <td><strong class="bodyText">Oggetto*[/b]</td>           
<td><input name="subject" type="text" id="subject" size="40" /></td>         </tr>         <tr>           <td valign="top"><strong class="bodyText"> Messaggio*[/b] </td>           <td><textarea name="body" cols="40" rows="7" id="body"></textarea></td>                    </tr>         <tr>           
<td class="bodyText">[b]Motivo del contatto * [/b]</td>           
<td><select name="motivo" size="1" class="bodyText" id="motivo">             
<option selected="selected">informazioni varie</option>             <option>informazioni gite</option>             
<option>informazioni corsi</option><option>segnalazioni varie</option>                          <option>segnala malfunzionamenti sito</option>             </select>             </td>         </tr>         <tr>           
<td><div align="left">[b]Inserisci il codice captcha[/b] (domanda antispam)</div></td>           
<td>[img]securimage/securimage_show.php?sid=<?php echo md5(uniqid(time())); ?>[/img]
<input type="text" name="code" /> </td></tr><tr>           
<td><span class="Stile27">* campi obbligatori </span></td>           
<td><input name="Submit" type="submit" onclick="MM_validateForm('emailAddress','','RisEmail','subject','','R','body','','R');return document.MM_returnValue" value="Invia" /></td>         </tr>       </table>   </form>
poi ho caricato sul sito lo script secureimage con i codici gia pronti ma a me invece di questo esempio incluso vorrei adattarlo al modulo di invio

l'esempio funzionante è questo:
Codice PHP:
<?php   session_start();  ?> <html> <head>   <title>Securimage Test Form</title> </head>  <body>  <?php if (empty($_POST)) { ?> <form method="POST"> Username:
 <input type="text" name="username" />
 Password:
 <input type="text" name="password" />
   [img]securimage_show.php?sid=<?php echo md5(uniqid(time())); ?>[/img]
 <input type="text" name="code" />
  <input type="submit" value="Submit Form" /> </form>  <?php } else { //form is posted   include("securimage.php");   $img = new Securimage();   $valid = $img->check($_POST['code']);    if($valid == true) {     echo "<center>Thanks, you entered the correct code.</center>";   } else {     echo "<center>Sorry, the code you entered was invalid.  <a href=\"javascript:history.go(-1)\">Go back</a> to try again.</center>";   } }  ?>  </body> </html>
quindi io vorrei che se il codice è giusto esegua il codice sottostante (classmail.php) altrimenti che vada a puntare dinuovo sulla pagina del modulo contattaci.php

questo è il mio codice

Codice PHP:
<?php  require("class.phpmailer.php");  $mail = new PHPMailer();  $mail->SetLanguage("it","./");  $mail->IsSMTP();                                   // send via SMTP  $mail->Host     = "mail.ggcaisavona.it"; // SMTP servers  $mail->SMTPAuth = false;     // turn on SMTP authentication  $mail->Username = "info@ggcaisavona.it";  // SMTP username  $mail->Password = "buranco"; // SMTP password  $mail->From     = $_POST['emailAddress'];  $mail->FromName = $_POST['name'];  $mail->AddAddress("info@ggcaisavona.it");  $mail->WordWrap = 100;                              // set word wrap  //$mail->AddAttachment("/tmp/image.jpg", "new.jpg");  $mail->IsHTML(false);                               // send as HTML    $mail->Subject  =  "Messaggio da [url]www.ggcaisavona.it:[/url] ". $_POST['motivo']." IP: ".$_SERVER['REMOTE_ADDR']." Server: ".@gethostbyaddr($_SERVER['REMOTE_ADDR']);  $mail->Body     =  $_POST['body'];  $mail->AltBody  =  "Questo &egrave; il corpo alternativo";  if(!$mail->Send()) { header("Location: ko.php"); exit; }  ?>

come integro il tutto?