Hi,
I developed a website with captcha image validation. I developed it with PHP Version 5.2.5 and i uploaded on PHP Version 4.3.11 server. Captcha image validation working with my server. But it is not working with my cient server. Here iam sending my code sample. Please help me to solve this problem.
enquiry.php

<?php session_start(); ?>
<html>
<body>
<?php
   if (isset($_POST['submitBtn'])){
      $secCode = isset($_POST['secCode']) ? strtolower($_POST['secCode']) : "";
      if ($secCode == $_SESSION['securityCode']) {
         echo "<p>The result code was valid!<br/></p>";
         unset($_SESSION['securityCode']);
         $result = true;
      }
      else {
         echo "<p>Sorry the security code is invalid! Please try it again!</p>";
         $result = false;
      }
   }
   
   if ((!isset($_POST['submitBtn'])) || (!$result)){
?> 
			<form action="thanks.php" method="post" >
                          <table width="100%" border="0" align="center" cellpadding="1" cellspacing="1">
                            <tr>
                              <td>Company Name</td>
                              <td>
							  <input name="name" id="name" type="text" class="textbox" /></td>
                            </tr>
                            <tr>
                              <td>
							  Please describe your requirements:</td>
                            </tr>
                            <tr>
                              <td><textarea name="Requirement" class="textareaBig"></textarea></td>
                            </tr>
                            <tr>
                              <td>
							  Enter the code shown on image</td>
                              <td>
                                 <input name="secCode" id="secCode" type="text" class="textbox" /></td>
                              <td>
								 <img src="securityCode.php" alt="security code" border="1" /></td>
                            </tr>
                            <tr>
                              <td align="center">
							  <input type="submit" name="submitBtn" value="Send" class="Bigbtn" />							  
							  </td>
                            </tr>
                          </table>
</form>
<?php
   } 
?>						

</body>
</html>

thanks.php

<?php
session_start();
$_POST['secCode']=strtolower($_POST['secCode']);
if($_POST['secCode']!=$_SESSION['securityCode']){
	header("location:enquiry.php?msg=code not matching");
	exit;

}
array($fieldNames);
array($fieldValues);

$email=$_REQUEST['email'];
$mailAddress = "vineeth.kumar@bhasin.in";


$i = 0;
while (list($key, $value) = each($HTTP_POST_VARS)) {
    $fieldNames[$i] = $key;
    $fieldValues[$i] = $value;
	$i++;
}
while (list($key, $value) = each($HTTP_GET_VARS)) {
    $fieldNames[$i] = $key;
    $fieldValues[$i] = $value;
    $i++;
}
sendEmail($mailAddress, $fieldNames, $fieldValues,$email);

function sendEmail($sendMail, $fieldNames, $fieldValues,$email) {
	$to = $sendMail;
	$subject = "General Comments/Enquiry/Suggestion";
	$mailheaders = "From: $email\nReply-To: $email";
	for ($i=0; $i < sizeof($fieldNames); $i++) {
		if (!($fieldNames[$i] == 'redirect') && !($fieldNames[$i] == 'function') && !($fieldNames[$i] == 'mailAddress') && !($fieldNames[$i] == 'fileName')) {
		    if ( !($i == 0) ) {
				$msg = $msg . "$fieldNames[$i] : $fieldValues[$i] \n";
	     	}
	     	else {
				$msg = "$fieldNames[$i] : $fieldValues[$i] \n";
	     	}
		}
    }
	mail($to, $subject, $msg, $mailheaders);
	
	
}

?>

secCode.php

<?php
session_start();

$width  = 120;
$height =  40;
$length =   5;

$baseList = '0123456789abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

$code    = "";
$counter = 0;

$image = @imagecreate($width, $height) or die('Cannot initialize GD!');

for( $i=0; $i<10; $i++ ) {
   imageline($image, 
         mt_rand(0,$width), mt_rand(0,$height), 
         mt_rand(0,$width), mt_rand(0,$height), 
         imagecolorallocate($image, mt_rand(150,255), 
                                    mt_rand(150,255), 
                                    mt_rand(150,255)));
}

for( $i=0, $x=0; $i<$length; $i++ ) {
   $actChar = substr($baseList, rand(0, strlen($baseList)-1), 1);
   $x += 10 + mt_rand(0,10);
   imagechar($image, mt_rand(3,5), $x, mt_rand(5,20), $actChar, 
      imagecolorallocate($image, mt_rand(0,155), mt_rand(0,155), mt_rand(0,155)));
   $code .= strtolower($actChar);
}
   
header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);

$_SESSION['securityCode'] = $code;

?>

Recommended Answers

All 3 Replies

Check to see if the other server has PHP GD installed

Check to see if the other server has PHP GD installed

Thank for your reply. Its enabled please check this
GD Support enabled
GD Version bundled (2.0.28 compatible)
FreeType Support enabled
FreeType Linkage with freetype
T1Lib Support enabled
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled

I got this through phpinfo()

Please review the Member Rules, specifically the "Keep it Organized" section regarding proper use of code tags. Without the tags, there is no toggle plain text option, and most of us will not bother troubleshooting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.