I wish to install the following type of message into the one page processor/form below:

if (md5($captcha) == $_SESSION['image_random_value']) 
        {/*  echo "<h2>Code $captcha valid </h2>\n"; */}
	       echo "<h3>Link cannot be send because you entered an invalid Code</h3>\n";
I am not having any luck with the installation although the code I am using works in other situations! I have stripped out some of the code to simplify.

Can I be put back on the right track ?

/////////// LINK FORM AND PROCCESOR (All on one page) VALIDATION STARTS HERE ////////////////////	
	$errors = array();
	function validate_form_items()
	    $form_items = array(		   
		"name"  => array(
		"regex" => "/^([a-zA-Z '-]+)$/",
		"error" => "<i> Appears in an improper format!</i>",),
		"email" => array(
		"regex" =>
		"error" => "<i> Enter a valid Email address!</i>",),
	    "captcha" => array(
		"regex" =>  "/md5$captcha/",
		"error" => "<i> Please enter a Validate Code!</i>",),);
	global $errors;		
		if(!preg_match($form_items["name"]["regex"], $_POST["m_name"]))
			$errors[] = "<b>Your Name:</b> ".$form_items["name"]["error"];
		if(!preg_match($form_items["email"]["regex"], $_POST["m_email"]))
			$errors[] = "<b>Your Email:</b> ".$form_items["email"]["error"];		
		if(!preg_match($form_items["captcha"]["regex"], $_POST["captcha"]))
			$errors[] = "<b>Validate Code:</b> ".$form_items["captcha"]["error"];
				return count($errors);	   
/////////FORM MAIL STARTS HERE//////////////////////////////////////////////////////////////////////////////////	
	function email($from, $from_name, $to, $message)
		//header("Location: thanku.html");return;

		$headers .= "From: ".$from."\r\n";
		$headers .= "Content-type: text/plain; charset=ISO-8859-1";		
		$domian_name = "www.domain.net";
		$subject = $from_name."- An invitation to view $domian_name";
		$your_message = "Hi!\r\n";
		$your_message.= ucfirst($from_name);
		$your_message.= "would like you to check out this website at $domian_name\r\n";
		if (mail($to,$subject,$message,$headers) ) {
			return true;
		} else {
			return false;
	function print_error($errors)
	{foreach($errors as $error)
		echo "<div style=\"font-size:14px; font-weight:normal; color:red;\"><span style=\"background-color:yellow\">$err</span><div>";		
//////////////POSTING AND THANK YOU STARTS HERE///////////////////////////////////////////////////////////////////////////	
	function form_process()
	    $captcha = $_POST['captcha'];//verification code
		$from_name = $_POST["m_name"];
		$fromm_email = $_POST["m_email"];
		$to = $_POST["f_email"].",".$_POST["f_email"];
		$message = $_POST["message"];		
		$error_count = validate_form_items();
		if($error_count == 0)		
		{if(email($fromm_email, $from_name, $to,)) header("Location: thanku.html");
		{global $errors; $errors[] = "Email could not be send at this time. <br />Please report this to the Webmaster.";} }		
		if(isset($_POST["submit"])) form_process();

<html><body><fieldset><legend>Link to my Friend/s.</legend><br />
Install your friend/'s email details to forward link to this website.<br /><br />
<i>Required *</i>
    <form id="link" method="post" action="<?php echo $PHP_SELF?>" >
    <div><?php global $errors; if(count($errors) != 0){ print_error($errors);} ?></div>	
	<label>My Name:*</label><input type="text" name="m_name" value="<?php echo $_POST["m_name"]?>" />
    <label>My Email:*</label><input type="text" name="m_email" value="<?php echo $_POST["m_email"]?>" />
    <label>Friend's Email:*</label><input type="text" name="f_email" value="<?php echo $_POST["f_email"]?>" />
	<img src="randomImage.php"/><input type="text" name="captcha" size="5" />	
    <input type="submit" name="submit" value="Send Website Link" />