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;
?>
PHP Captcha Problem -- Please help me
Moderator: General Moderators
- andym01480
- Forum Contributor
- Posts: 390
- Joined: Wed Apr 19, 2006 5:01 pm
Re: PHP Captcha Problem -- Please help me
Captcha code filename is different from the filename being called in the image tag.
Re: PHP Captcha Problem -- Please help me
Hi,
Thanks for your help.
I renamed image file name. Now also its not validating.
Thanks for your help.
I renamed image file name. Now also its not validating.
- andym01480
- Forum Contributor
- Posts: 390
- Joined: Wed Apr 19, 2006 5:01 pm
Re: PHP Captcha Problem -- Please help me
Code: Select all
<?php
session_start(); //on a new line
?>
<html>
<body>
<?php
if (isset($_POST['submitBtn'])){
$secCode = isset($_POST['secCode']) ? strtolower($_POST['secCode']) : "";
echo '<pre>POST:'.print_r($_POST).'</pre><pre>SESSION:'.print_r($_SESSION).'</pre>';//for debugging
Post the o/p please
Re: PHP Captcha Problem -- Please help me
hi,
I changed the code. Now page is moving to the next page. It is not checking the captcha image security code. And next page is displaying blank screen. Please check my code
I changed the code. Now page is moving to the next page. It is not checking the captcha image security code. And next page is displaying blank screen. Please check my code
Code: Select all
<?php
session_start();
?>
<!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>
<title>Shibaam Polymers</title>
<script src="../Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script type="text/javascript" src="../includes/MenuScript.js"></script>
<link href="../includes/shibaam.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
if (isset($_POST['submitBtn'])){
$secCode = isset($_POST['secCode']) ? strtolower($_POST['secCode']) : "";
echo '<pre>POST:'.print_r($_POST).'</pre><pre>SESSION:'.print_r($_SESSION).'</pre>';//for debugging
$_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);
}
?>
</body>
</html>
- andym01480
- Forum Contributor
- Posts: 390
- Joined: Wed Apr 19, 2006 5:01 pm
Re: PHP Captcha Problem -- Please help me
post what appears in your browser after you press submit please.
Re: PHP Captcha Problem -- Please help me
Hi
Thank for your earliest reply. Please check the attached screen shot
Thank for your earliest reply. Please check the attached screen shot
- Attachments
-
- screen shot
- Screenshot.png (81.23 KiB) Viewed 558 times
Re: PHP Captcha Problem -- Please help me
Hi,
I rectified this problem now captcha is working fine.
Thanks for your help...
--
Vineeth
I rectified this problem now captcha is working fine.
Thanks for your help...
--
Vineeth