Jump to content

php contact form help


tarzan

Recommended Posts

i would like some help please,i have completed my contact form but would like some guidance on how to get a captcha working.

 

what i would like is the error message to appear like the other error messages within the form as per code below.

 

contactform.php

<form name="form1" method="post" action="">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="31%"><div align="right"></div></td>
<td width="69%">
       			  
       			  <div align="left">
       			      <?php
		  	  	if ($_POST && isset($missing)) {
		  	  	?>
	              <span class="warning style14">Please complete the required item(s) indicated.</span></div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><div align="left">
          			<?php
	          	}
	          	elseif ($_POST && !$mailSent) {
			  	?>
				<span class="warning style14">Sorry, there was a problem sending your message. Please try later.</span></div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><div align="left">
          			<?php
	          	}
	          	elseif ($_POST && $mailSent) {
			  	?>
				<span class="style13">Your message has been Successfully sent. </span></div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><div align="left">
				<?php } ?> 
</div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td> </td>
</tr>
<tr>
<td valign="bottom"><div align="right"></div></td>
<td> </td>
</tr>
<tr>
<td valign="bottom"><div align="right"></div></td>
<td><p align="left"><span class="style29">* </span> <span class="style17">Your Name : </span><span class="style14">
          			<?php
				if (isset($missing) && in_array('name', $missing)) { ?>
				<span class="warning style14">Please Enter Your Name  </span>
				<?php } ?>
</span></p></td>
</tr>
<tr>
<td valign="bottom"><div align="right"></div></td>
<td>
       			<div align="left">
           		  <input name="name" type="text" id="name" size="50" maxlength="90"
				<?php if (isset($missing)) {
				  echo 'value="'.htmlentities($_POST['name']).'"';} ?>
				  />

</div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td> </td>
</tr>
<tr>
<td valign="bottom"><div align="right"></div></td>
<td><span class="style27">* </span> <span class="style17">Your E-mail :
          			<?php
				if (isset($missing) && in_array('email', $missing)) { ?>
          			<span class="warning style14">Please Enter Your E-mail  </span>
				<?php } ?>
</span></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td>
<div align="left">
  <input name="email" type="text" id="email" size="50" maxlength="90"
				<?php if (isset($missing)) {
			      echo 'value="'.htmlentities($_POST['email']).'"';} ?>
				/>
</div></td>
</tr>
<tr>
<td valign="top"><div align="right"></div></td>
<td> </td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><div align="left">
          			<p><span class="style27">*</span> <span class="style19 style20">Your Subject :</span>
            		<?php
				if (isset($missing) && in_array('subject', $missing)) { ?>
            		<span class="warning style14">Please Enter Your Subject   </span>
				<?php } ?>
</p>
</div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><div align="left">
  <input name="subject" type="text" id="subject" size="50" maxlength="90"
				<?php if (isset($missing)) {
				  echo 'value="'.htmlentities($_POST['subject']).'"';} ?>
				/>
</div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td> </td>
</tr>
<tr>
<td valign="bottom"><div align="right"></div></td>
<td><div align="left">
<div align="left">
				<p><span class="style29">* </span><span class="style17">Your Message  :</span>
               		<?php
				if (isset($missing) && in_array('message', $missing)) { ?>
              		<span class="warning style14">Please Enter Your Message   </span>
              		<?php } ?>
</p>
</div>
</div></td>
</tr>
<tr>
<td valign="top"><div align="right"></div></td>
<td>				<textarea name="message" cols="60" rows="8" id="message"><?php 
				if (isset($missing)) {
			  	echo htmlentities($_POST['message']);
			    } ?></textarea></tr>
<tr>
<td><div align="right"></div></td>
<td> </td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><div align="left">(captcha image goes here)</div></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><div align="left"><span class="style29">* </span><span class="style17">Type Security Code   :</span><span class="style29">
			  <?php
				if (isset($missing) && in_array('verif_box', $missing)) { ?>
                    <span class="warning style14">Please Enter Security Code </span>
                    <?php } ?>
				</span></div></td>
</tr>
<tr>
        <td> </td>
        <td><div align="left">
          <input type="password" name="password" size="10"/>
        </div></td>
      </tr>
      <tr>
        <td> </td>
        <td><div align="left"></div></td>
      </tr>
      <tr>
        <td> </td>
        <td><input name="send" id="send" type="submit" value="Send Message" class="button" /></td>
      </tr>
      <tr>
        <td> </td>
        <td><label></label></td>
      </tr>
    </table>
  </form>

 

 

formprocess.php

<?php
include('corefuncs.php');
if (function_exists('nukeMagicQuotes')) {
  nukeMagicQuotes();
  }

// process the email
if (array_key_exists('send', $_POST)) {
  $to = '[email protected]'; // use your own email address
  $heading = '**You Have Mail**';
  
  // list expected fields
  $expected = array('name', 'email', 'subject', 'message', 'vericode');
  // set required fields
  $required = array('name', 'email', 'subject', 'message', 'vericode');
  // create empty array for any missing fields
  $missing = array();
  
  // assume that there is nothing suspect
  $suspect = false;
  // create a pattern to locate suspect phrases
  $pattern = '/Content-Type:|Bcc:|Cc:/i';
  
  // function to check for suspect phrases
  function isSuspect($val, $pattern, &$suspect) {
    // if the variable is an array, loop through each element
// and pass it recursively back to the same function
if (is_array($val)) {
      foreach ($val as $item) {
    isSuspect($item, $pattern, $suspect);
    }
  }
    else {
      // if one of the suspect phrases is found, set Boolean to true
  if (preg_match($pattern, $val)) {
        $suspect = true;
    }
  }
    }
  
  // check the $_POST array and any sub-arrays for suspect content
  isSuspect($_POST, $pattern, $suspect);
  
  if ($suspect) {
    $mailSent = false;
unset($missing);
}
  else {
    // process the $_POST variables
    foreach ($_POST as $key => $value) {
      // assign to temporary variable and strip whitespace if not an array
      $temp = is_array($value) ? $value : trim($value);
  // if empty and required, add to $missing array
  if (empty($temp) && in_array($key, $required)) {
    array_push($missing, $key);
    }
  // otherwise, assign to a variable of the same name as $key
  elseif (in_array($key, $expected)) {
    ${$key} = $temp;
    }
  }
}
  
  // validate the email address
  if (!empty($email)) {
    // regex to ensure no illegal characters in email address 
$checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
// reject the email address if it doesn't match
if (!preg_match($checkEmail, $email)) {
  array_push($missing, 'email');
  }
}
  
  // go ahead only if not suspect and all required fields OK
  if (!$suspect && empty($missing)) {
    // build the message
    $comments = "Name: $name\n\n";
    $comments .= "Email: $email\n\n";
    $comments .= "Message: $message";

    // limit line length to 70 characters
    $comments = wordwrap($comments, 70);
    
// create additional headers
$additionalHeaders = 'From: <WebContact>';
if (!empty($email)) {
  $additionalHeaders .= "\r\nReply-To: $email";
  }

    // send it  
    $mailSent = mail($to, $heading, $comments, $additionalHeaders);
if ($mailSent) {
  // $missing is no longer needed if the email is sent, so unset it
  unset($missing);
  }
    }
  }
?>

 

any help in finishing this off would be fantastic guys.

 

thank you in advance

Link to comment
https://forums.phpfreaks.com/topic/121744-php-contact-form-help/
Share on other sites

sorry about this guys....please forgive me.

 

please disregard the above post i made.

 

i have found this and it looks good so i will be using it.

i have managed to get the captcha working but i have a little problem i don't know how to rectify,what happens is when you fill out the form without inserting the captcha code it submits and says thanks for sending message,this is not supposed to do this it is supposed to ask you to fill out the captcha so this tells me that something is not quite right,was wondering if someone could help us out at all pleasse.

 

<?php
session_start();
if(isset($_POST["code"])) {
if(($_SESSION['captcha_code'] == $_POST['code']) && (!empty($_SESSION['captcha_code'])) ) {
	//Passed!
	$captcha_msg="Thank you";
}else{
	// Not passed 8-(
	$captcha_msg="invalid code";
	if(isset($_POST["MM_insert"])){
  		unset($_POST["MM_insert"]);
	}
	if(isset($_POST["MM_update"])){
		unset($_POST["MM_update"]);
	}
}
}
class CaptchaImage {
var $font = "verdana.ttf";
function hex_to_dec($hexcolor){
//convert hex hex values to decimal ones
$dec_color=array('r'=>hexdec(substr($hexcolor,0,2)),'g'=>hexdec(substr($hexcolor,2,2)),'b'=>hexdec(substr($hexcolor,4,2)));
return $dec_color;
}
function generateCode($characters) {
	/* list all possible characters, similar looking characters and vowels have been removed */
	$possible = '23456789bcdfghjkmnpqrstvwxyz'; 
	$code = '';
	$i = 0;
	while ($i < $characters) { 
		$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
		$i++;
	}
	return $code;
}
function CaptchaImage($width='120',$height='30',$characters='6',$hex_bg_color='FFFFFF',$hex_text_color="FF0000",$hex_noise_color="CC0000", $img_file='captcha.jpg') {
	$rgb_bg_color=$this->hex_to_dec($hex_bg_color);
	$rgb_text_color=$this->hex_to_dec($hex_text_color);
	$rgb_noise_color=$this->hex_to_dec($hex_noise_color);
	$code = $this->generateCode($characters);
	/* font size will be 60% of the image height */
	$font_size = $height * 0.60;
	$image = @imagecreate($width, $height) or die('Cannot Initialize new GD image stream');
	/* set the colours */
	$background_color = imagecolorallocate($image, $rgb_bg_color['r'], $rgb_bg_color['g'],$rgb_bg_color['b']);
	$text_color = imagecolorallocate($image, $rgb_text_color['r'], $rgb_text_color['g'],$rgb_text_color['b']);
	$noise_color = imagecolorallocate($image, $rgb_noise_color['r'], $rgb_noise_color['g'],$rgb_noise_color['b']);
	/* generate random dots in background */
	for( $i=0; $i<($width*$height)/3; $i++ ) {
		imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
	}
	/* generate random lines in background */
	for( $i=0; $i<($width*$height)/150; $i++ ) {
		imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
	}
	/* create textbox and add text */
	$textbox = imagettfbbox($font_size, 0, $this->font, $code);
	$x = ($width - $textbox[4])/2;
	$y = ($height - $textbox[5])/2;
	imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code);
	/* save the image */
	imagejpeg($image,$img_file);
	imagedestroy($image);
	echo "<img src=\"$img_file?".time()."\" width=\"$width\" height=\"$height\" alt=\"security code\" id=\"captchaImg\">";
	$_SESSION['captcha_code'] = $code;
}

}
?>
<?php include('includes/corefuncs.php');
if (function_exists('nukeMagicQuotes')) {
  nukeMagicQuotes();
  }

// process the email
if (array_key_exists('send', $_POST)) {
  $to = '[email protected]'; // use your own email address
  $subject = 'PUT THE SUBJECT OF THE EMAIL HERE';
  
  // list expected fields
  $expected = array('name', 'email', 'comments');
  // set required fields
  $required = array('name', 'email', 'comments');
  // create empty array for any missing fields
  $missing = array();
  
  // assume that there is nothing suspect
  $suspect = false;
  // create a pattern to locate suspect phrases
  $pattern = '/Content-Type:|Bcc:|Cc:/i';
  
  // function to check for suspect phrases
  function isSuspect($val, $pattern, &$suspect) {
    // if the variable is an array, loop through each element
// and pass it recursively back to the same function
if (is_array($val)) {
      foreach ($val as $item) {
    isSuspect($item, $pattern, $suspect);
    }
  }
    else {
      // if one of the suspect phrases is found, set Boolean to true
  if (preg_match($pattern, $val)) {
        $suspect = true;
    }
  }
    }
  
  // check the $_POST array and any sub-arrays for suspect content
  isSuspect($_POST, $pattern, $suspect);
  
  if ($suspect) {
    $mailSent = false;
unset($missing);
}
  else {
    // process the $_POST variables
    foreach ($_POST as $key => $value) {
      // assign to temporary variable and strip whitespace if not an array
      $temp = is_array($value) ? $value : trim($value);
  // if empty and required, add to $missing array
  if (empty($temp) && in_array($key, $required)) {
    array_push($missing, $key);
    }
  // otherwise, assign to a variable of the same name as $key
  elseif (in_array($key, $expected)) {
    ${$key} = $temp;
    }
  }
}
  
  // validate the email address
  if (!empty($email)) {
    // regex to ensure no illegal characters in email address 
$checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
// reject the email address if it doesn't match
if (!preg_match($checkEmail, $email)) {
  array_push($missing, 'email');
  }
}
  
  // go ahead only if not suspect and all required fields OK
  if (!$suspect && empty($missing)) {
    // build the message
    $message = "Name: $name\n\n";
    $message .= "Email: $email\n\n";
    $message .= "Comments: $comments";

    // limit line length to 70 characters
    $message = wordwrap($message, 70);
    
// create additional headers
$additionalHeaders = 'From: <[email protected]>';
if (!empty($email)) {
  $additionalHeaders .= "\r\nReply-To: $email";
  }

    // send it  
    $mailSent = mail($to, $subject, $message, $additionalHeaders);
if ($mailSent) {
  // $missing is no longer needed if the email is sent, so unset it
  unset($missing);
  }
    }
  }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Contact Our Company</title>
<link href="assets/formstyle.css" rel="stylesheet" type="text/css" media="screen" />
</head>

<body>


    
    <div id="form-wrap">
<div id="form-area">
        <h1><p>Contact</h1>
	<p>
	      <?php
	if ($_POST && isset($missing)) {
	?>
        <span class="warning">Please complete the missing item(s) indicated.</span></p>
	<p>
	      <?php
	  }
	elseif ($_POST && !$mailSent) {
	?>
        <span class="warning">Sorry, there was a problem sending your message. Please try later.</span></p>
	<p>
	      <?php
	  }
	elseif ($_POST && $mailSent) {
	?>
            <strong>Your message has been sent. Thank you for your feedback.</strong></p>
	<p>
	      <?php } ?>
	</p>
	<form id="feedback" method="post" action="">
            <p>
                <label for="name">Name: <?php
			if (isset($missing) && in_array('name', $missing)) { ?>
			<span class="warning">Please enter your name</span><?php } ?>
			</label>
                <input name="name" id="name" type="text" class="formbox" 
			<?php if (isset($missing)) {
			  echo 'value="'.htmlentities($_POST['name']).'"';} ?>
			/>
            </p>
            <p>
                <label for="email">Email: <?php
			if (isset($missing) && in_array('email', $missing)) { ?>
			<span class="warning">Please enter a valid email address</span><?php } ?>
			</label>
                <input name="email" id="email" type="text" class="formbox" 
			<?php if (isset($missing)) {
			  echo 'value="'.htmlentities($_POST['email']).'"';} ?>
			/>
            </p>
            <p>
                <label for="comments">Comments: <?php
			if (isset($missing) && in_array('comments', $missing)) { ?>
			<span class="warning">Please enter your comments</span><?php } ?>
			</label>
                <textarea name="comments" id="comments" cols="60" rows="8"><?php 
			if (isset($missing)) {
			  echo htmlentities($_POST['comments']);
			  } ?></textarea>
            </p>
            <p>
                  <?php $captcha = new CaptchaImage(150,50,5,'FFFFFF','FF0000','999999');?></p>
            <p>
                  <label for="code">Code: <?php echo $captcha_msg ?></label>
                <input name="code" id="code" type="text" class="formbox" 
			/>
            <p>
                <input name="send" id="send" type="submit" value="Send message" class="button" />
            </p>
        </form>
</div>
</div>

</body>
</html>

 

also do you recommend i take the process part out and put it into another file and name it something like formprocess.php or keep the code where it is?

 

 

oh i am getting so close.....i have managed to get the error message working which is a great achievement for me i tell ya.

 

however, when testing the script out i thought it worked just fine.all the error messages in the right place,and at the right time when you hit submit,but i noticed that when i inserted the security code with 1 letter wrong it still submitted so that tells me that the error reporting on the security code bit is not working correctly.in other words it's not checking to see if the correct code was inputted...hmmm

 

now i have changed the code as follows.

<?php
session_start();
if(isset($_POST["code"])) {
if(($_SESSION['captcha_code'] == $_POST['code']) && (!empty($_SESSION['captcha_code'])) ) {
	//Passed!
	$captcha_msg="";
}else{
	// Not passed 8-(
	$captcha_msg="";
	if(isset($_POST["MM_insert"])){
  		unset($_POST["MM_insert"]);
	}
	if(isset($_POST["MM_update"])){
		unset($_POST["MM_update"]);
	}
}
}
class CaptchaImage {
var $font = "verdana.ttf";
function hex_to_dec($hexcolor){
//convert hex hex values to decimal ones
$dec_color=array('r'=>hexdec(substr($hexcolor,0,2)),'g'=>hexdec(substr($hexcolor,2,2)),'b'=>hexdec(substr($hexcolor,4,2)));
return $dec_color;
}
function generateCode($characters) {
	/* list all possible characters, similar looking characters and vowels have been removed */
	$possible = '23456789bcdfghjkmnpqrstvwxyz'; 
	$code = '';
	$i = 0;
	while ($i < $characters) { 
		$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
		$i++;
	}
	return $code;
}
function CaptchaImage($width='120',$height='30',$characters='6',$hex_bg_color='FFFFFF',$hex_text_color="FF0000",$hex_noise_color="CC0000", $img_file='captcha.jpg') {
	$rgb_bg_color=$this->hex_to_dec($hex_bg_color);
	$rgb_text_color=$this->hex_to_dec($hex_text_color);
	$rgb_noise_color=$this->hex_to_dec($hex_noise_color);
	$code = $this->generateCode($characters);
	/* font size will be 60% of the image height */
	$font_size = $height * 0.60;
	$image = @imagecreate($width, $height) or die('Cannot Initialize new GD image stream');
	/* set the colours */
	$background_color = imagecolorallocate($image, $rgb_bg_color['r'], $rgb_bg_color['g'],$rgb_bg_color['b']);
	$text_color = imagecolorallocate($image, $rgb_text_color['r'], $rgb_text_color['g'],$rgb_text_color['b']);
	$noise_color = imagecolorallocate($image, $rgb_noise_color['r'], $rgb_noise_color['g'],$rgb_noise_color['b']);
	/* generate random dots in background */
	for( $i=0; $i<($width*$height)/3; $i++ ) {
		imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
	}
	/* generate random lines in background */
	for( $i=0; $i<($width*$height)/150; $i++ ) {
		imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
	}
	/* create textbox and add text */
	$textbox = imagettfbbox($font_size, 0, $this->font, $code);
	$x = ($width - $textbox[4])/2;
	$y = ($height - $textbox[5])/2;
	imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code);
	/* save the image */
	imagejpeg($image,$img_file);
	imagedestroy($image);
	echo "<img src=\"$img_file?".time()."\" width=\"$width\" height=\"$height\" alt=\"security code\" id=\"captchaImg\">";
	$_SESSION['captcha_code'] = $code;
}

}
?>
<?php include('includes/corefuncs.php');
if (function_exists('nukeMagicQuotes')) {
  nukeMagicQuotes();
  }

// process the email
if (array_key_exists('send', $_POST)) {
  $to = '[email protected]'; // use your own email address
  $heading = '**You Have Mail**';
  
  // list expected fields
  $expected = array('name', 'email', 'subject', 'message', 'code');
  // set required fields
  $required = array('name', 'email', 'subject', 'message', 'code');
  // create empty array for any missing fields
  $missing = array();
  
  // assume that there is nothing suspect
  $suspect = false;
  // create a pattern to locate suspect phrases
  $pattern = '/Content-Type:|Bcc:|Cc:/i';
  
  // function to check for suspect phrases
  function isSuspect($val, $pattern, &$suspect) {
    // if the variable is an array, loop through each element
// and pass it recursively back to the same function
if (is_array($val)) {
      foreach ($val as $item) {
    isSuspect($item, $pattern, $suspect);
    }
  }
    else {
      // if one of the suspect phrases is found, set Boolean to true
  if (preg_match($pattern, $val)) {
        $suspect = true;
    }
  }
    }
  
  // check the $_POST array and any sub-arrays for suspect content
  isSuspect($_POST, $pattern, $suspect);
  
  if ($suspect) {
    $mailSent = false;
unset($missing);
}
  else {
    // process the $_POST variables
    foreach ($_POST as $key => $value) {
      // assign to temporary variable and strip whitespace if not an array
      $temp = is_array($value) ? $value : trim($value);
  // if empty and required, add to $missing array
  if (empty($temp) && in_array($key, $required)) {
    array_push($missing, $key);
    }
  // otherwise, assign to a variable of the same name as $key
  elseif (in_array($key, $expected)) {
    ${$key} = $temp;
    }
  }
}
  
  // validate the email address
  if (!empty($email)) {
    // regex to ensure no illegal characters in email address 
$checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
// reject the email address if it doesn't match
if (!preg_match($checkEmail, $email)) {
  array_push($missing, 'email');
  }
}
  
  // go ahead only if not suspect and all required fields OK
  if (!$suspect && empty($missing)) {
    // build the message
    $comments = "Name: $name\n\n";
    $comments .= "Email: $email\n\n";
    $comments .= "Message: $message";

    // limit line length to 70 characters
    $message = wordwrap($message, 70);
    
// create additional headers
$additionalHeaders = 'From: <WebContact>';
if (!empty($email)) {
  $additionalHeaders .= "\r\nReply-To: $email";
  }

    // send it  
    $mailSent = mail($to, $heading, $comments, $additionalHeaders);
if ($mailSent) {
  // $missing is no longer needed if the email is sent, so unset it
  unset($missing);
  }
    }
  }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Contact Our Company</title>
<link href="assets/formstyle.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css">
<!--
.style1 {
color: #00FF00;
font-weight: bold;
font-style: italic;
}
.style4 {color: #FF0000; font-style: italic; }
-->
</style>
</head>

<body>


    

<div id="form-area">
      <p>
	      <?php
	if ($_POST && isset($missing)) {
	?>
        <span class="warning"><em>Please complete the missing item(s) indicated.</em></span></p>
	<p>
	      <?php
	  }
	elseif ($_POST && !$mailSent) {
	?>
        <span class="warning"><em>Sorry, there was a problem sending your message. Please try later.</em></span></p>
	<p>
	      <?php
	  }
	elseif ($_POST && $mailSent) {
	?>
            <span class="style1">Thank You....Your Message Was Successfully Sent. </span></p>
	<p>
	      <?php } ?>
	</p>
	<p>  </p>
	<form id="feedback" method="post" action="">
            <p>
                <label for="name"><span class="style4">*</span><em> Your Name:</em> 
                <?php
			if (isset($missing) && in_array('name', $missing)) { ?>
			<span class="warning"><em>Please Enter Your Name !! </em></span>
			<?php } ?>
			</label>
                <input name="name" id="name" type="text" class="formbox" 
			<?php if (isset($missing)) {
			  echo 'value="'.htmlentities($_POST['name']).'"';} ?>
			/>
            </p>
            <p>
                <label for="email"><span class="style4">*</span><em> Your E-mail :</em> 
                <?php
			if (isset($missing) && in_array('email', $missing)) { ?>
			<span class="warning"><em>Please Enter Your E-mail !! </em></span>
			<?php } ?>
			</label>
                <input name="email" id="email" type="text" class="formbox" 
			<?php if (isset($missing)) {
			  echo 'value="'.htmlentities($_POST['email']).'"';} ?>
			/>
            </p>
	   <p>
			<label for="subject"><span class="style4">*</span><em> Your Subject:</em> 
                <?php
			if (isset($missing) && in_array('subject', $missing)) { ?>
			<span class="warning"><em>Please Enter Your Subject !! </em></span>
			<?php } ?>
			</label>
                <input name="subject" id="subject" type="text" class="formbox" 
			<?php if (isset($missing)) {
			  echo 'value="'.htmlentities($_POST['subject']).'"';} ?>
			/>
		</p>
	   <p>
                <label for="message"><span class="style4">*</span><em> Your Message :</em> 
                <?php
			if (isset($missing) && in_array('message', $missing)) { ?>
			<span class="warning"><em>Please Enter Your Message !! </em></span>
			<?php } ?>
			</label>
                <textarea name="message" id="message" cols="60" rows="8"><?php 
			if (isset($missing)) {
			  echo htmlentities($_POST['message']);
			  } ?></textarea>
            </p>
           <p>
                  <?php $captcha = new CaptchaImage(150,50,5,'FFFFFF','FF0000','999999');?></p>
           <p>
                  <label for="code"><span class="style4">*</span><em> Type Security Code :</em>
                  <?php
			if (isset($missing) && in_array('code', $missing)) { ?>
                  <span class="warning"><em>Please Enter Security Code!! </em></span>
                  <?php } ?>
                  </label>
                <input name="code" id="code" type="text" class="formbox"
			 <?php if (isset($missing)) {
			  echo 'value="'.htmlentities($_POST['code']).'"';} ?>
			/>
           <p>
                <input name="send" id="send" type="submit" value="Send Message" class="button" />
           </p>
        </form>
</div>
</div>

</body>
</html>

 

notice this part.

<?php $captcha = new CaptchaImage(150,50,5,'FFFFFF','FF0000','999999');?></p>
           <p>
                  <label for="code"><span class="style4">*</span><em> Type Security Code :</em>
                  <?php
			if (isset($missing) && in_array('code', $missing)) { ?>
                  <span class="warning"><em>Please Enter Security Code!! </em></span>
                  <?php } ?>
                  </label>
                <input name="code" id="code" type="text" class="formbox"
			 <?php if (isset($missing)) {
			  echo 'value="'.htmlentities($_POST['code']).'"';} ?>
			/>
           <p>
                <input name="send" id="send" type="submit" value="Send Message" class="button" />
           </p>
        </form>

 

i have the error reporting setup ok but like i said it's not checking to see if the right code was inputted.

any suggestions?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.