PDA

View Full Version : Simple Form Processing Script + Captcha Issue


kremo5le
10-14-2009, 03:30 AM
Hello guys,

I'm working on a simple form for a client which is 100% done. He wanted a captcha and I did install it on the form and tested and it worked wonderfully. However, when I placed the PHP code within the new template page it does not work. I think is because there is more PHP going around in there and I have no clue on how to fix it. However, this is code the client placed in there and I do not want to touch anything that could modify it UNLESS it is to make mine work!

PAGE CODE (What I added starts on line 205 & ends on 224):

<?php
/**
* validateManageComponent($input = component name)
*/
if ( is_file( dirname(__FILE__) . "/scripts/rvslib/component/rvsManageComponent.php") ) {
include( dirname(__FILE__) . "/scripts/rvslib/component/rvsManageComponent.php");
rvsManageComponent::validateManageComponent('Onlin e_Form');
} elseif ( is_file( dirname(dirname(__FILE__)) . "/.rvsitebuilder/rvsManageComponent.php") ) {
include( dirname(dirname(__FILE__)) . "/.rvsitebuilder/rvsManageComponent.php");
rvsManageComponent::validateManageComponent('Onlin e_Form');
}
?>



<!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" xml:lang="en" lang="en">

<head>

<title>EBG - Message Status</title>


<meta http-equiv="Content-Type" content="text/html; charset =iso-8859-15" />
<meta name="keywords" content="" />
<meta name="description" content="" />



<link rel="stylesheet" href="http://ecossebg.com/style.css" type="text/css" />

<link rel="stylesheet" href="http://ecossebg.com/Arial.css" type="text/css" />
<link rel="stylesheet" href="http://ecossebg.com/2a1f96cb8d8172207002d92b0a82bc3a.css" type="text/css" />
<link rel="stylesheet" href="http://ecossebg.com/pathway.css" type="text/css" />



<script language="JavaScript" type="text/javascript" src="http://ecossebg.com/rvsincludefile/rvsnavigator.js"></script>


<script language="JavaScript" type="text/javascript" src="http://ecossebg.com/js/layersmenu-library.js"></script>
<script language="JavaScript" type="text/javascript" src="http://ecossebg.com/js/layersmenu.js"></script>

<script language="JavaScript" type="text/javascript" src="http://ecossebg.com/rvsincludefile/rvscustomopenwindow.js"></script>



</head>



<body >

<table cellpadding="0" cellspacing="0" id="rv_top_adjust_width_0" width="100%" align="Center" >

<tr>

<td>

<!-- START LOGO -->

<div style="position: absolute;">

<div id="Layer1" style="position:relative; left:100px; top:30px; width:120; height:60; text-align:center; z-index:1; overflow:visible; white-space:nowrap;"></div>

</div>

<div style="position: absolute;">

<div id="Layer2" style="position:relative; left:37px; top:69px; width:auto; height:auto; text-align:left; z-index:2; overflow:visible; white-space:nowrap;" class="company">Ecosse Business Group, LLC</div>

</div>

<div style="position: absolute;">

<div id="Layer3" style="position:relative; left:58px; top:123px; width:auto; height:auto; text-align:left; z-index:3; overflow:visible; white-space:nowrap;" class="slogan">Where experience counts</div>

</div>

<!-- END LOGO -->

<table cellpadding="0" cellspacing="0" width="100%">

<tr>

<td><img src="images/img_01.jpg" alt="" width="273" height="167" /></td>

<td class="bgtop" width="99%"></td>

<td><img src="images/img_02.jpg" alt="" width="247" height="167" /></td>

<td><img src="images/img_03.jpg" alt="" width="260" height="167" /></td>

</tr>

</table>

</td>

</tr>

<tr>

<td bgcolor="#ffffff">

<table cellpadding="0" cellspacing="0" width="100%">

<tr>

<td class="bg_l"><img src="images/spacer.gif" alt="" width="22" height="1" /></td>

<td align="left" valign="top" width="99%">

<table cellpadding="0" cellspacing="0" width="100%">

<tr>

<td align="left" valign="top" height="32" width="99%" class="menu"><div id="navigator">
<ul id="navigator">
<li><a href="index.php" id="normal" target="_self" ><span>Home</span></a></li>
<li><a href="About-us.php" id="normal" target="_self" ><span>About us</span></a></li>
<li><a href="Services.php" id="normal" target="_self" ><span>Services</span></a></li>
<li><a href="Green-Products.php" id="normal" target="_self" ><span>Green Products</span></a></li>
<li><a href="Contact-Us.php" id="current" target="_self" ><span>Contact Us</span></a></li>
<li><a href="News--and--Events.php" id="normal" target="_self" ><span>News &amp; Events</span></a></li>
</ul>
</div>

</td>

</tr>

<tr>

<td width="99%" align="left" valign="top">

<table cellpadding="0" cellspacing="0" width="100%">

<tr>

<td width="99%"><img src="images/spacer.gif" alt="" width="1" height="4" /></td>

</tr>

<tr>

<td>

<table cellpadding="0" cellspacing="0" width="100%">





<!-- Begin PATHWAY and ICON -->

<tr>

<td class="magin">

<table cellpadding="0" cellspacing="0" width="100%">

<tr>

<!-- Begin PATHWAY -->

<td align="left" width="99%"><?php $thisPage = (defined("RVS_COMPONENT_NAME")) ? RVS_COMPONENT_NAME . "-utf-8" : "form";
include("/home/ecosseb1/public_html/rvsincludefile/pathway_" . $thisPage . ".html"); ?></td>

<!-- End PATHWAY -->

<!-- Begin ICON -->

<td align="right"></td>

<!-- End ICON -->

</tr>

</table>

</td>

</tr>

<!-- End PATHWAY and ICON -->

<tr>

<td align="left" valign="top">

<table cellpadding="0" cellspacing="0" width="100%">

<tr>





<td align="left" valign="top" class="magin" id="rv_adjust_width_63" width="100%">

<p>&nbsp;</p>
<p>
<?php

if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='') {
echo '<strong>Incorrect verification code. Please go back and try again.</strong><br>';
} else {
// Form Data
$message = "Name:".$_POST["name"]. "\r\n";
$message .= "Email".$_POST["email"]. "\r\n";
$message .= "Message:".$_POST["message"]. "\r\n";

$to = "cs@domain.com";
$subject = "domain.com Contact Request";
$headers = "From: info@domain.com\r\n";
if (mail($to,$subject,$message,$headers));
else
return false;
//End Form Data
echo '<strong>Email sent successfully. We will contact you soon!</strong><br>';
};
?>


</p>
<p>&nbsp;</p></td>





</tr>

</table>

</td>

</tr>

<!-- Begin FOOTER -->

<tr>

<td align="center" class="magin"></td>

</tr>

<!-- End FOOTER -->





<tr>

<td align="center" valign="bottom">

<table cellpadding="0" cellspacing="0">

<tr>

<td align="center" valign="bottom" class="marginpw"></td>

<td width="8"></td>

<td align="center" valign="bottom" class="marginpw"></td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

<td class="bg_r"><img src="images/spacer.gif" alt="" width="18" height="1" /></td>

</tr>

</table>

</td>

</tr>

<tr>

<td>

<table cellpadding="0" cellspacing="0" width="100%">

<tr>

<td><img src="images/img_04.jpg" alt="" width="36" height="37" /></td>

<td class="menu" width="99%"></td>

<td><img src="images/img_05.jpg" alt="" width="32" height="37" /></td>

</tr>

</table>

</td>

</tr>

</table>

</body>



</html>

Thank you before hand guys!:-D

bee80
10-14-2009, 07:46 AM
thats horrible code :), i cant see where your outputting your captcha image? and you havnt started a session at the top of the page

kremo5le
10-14-2009, 04:22 PM
thats horrible code :), i cant see where your outputting your captcha image? and you havnt started a session at the top of the page

It is my friend. I just can't do anything because is what the client has. I could suggest to fix it, my frist priority, but you know many clients want what they want and "everything else is working fine. Why do you want to change it?" kind of question.

The captcha is called (captcha.php) and this is the code:

<?php
session_start();
$text = rand(10000,99999);
$_SESSION["vercode"] = $text;
$height = 25;
$width = 65;

$image_p = imagecreate($width, $height);
$black = imagecolorallocate($image_p, 0, 0, 0);
$white = imagecolorallocate($image_p, 255, 255, 255);
$font_size = 14;

imagestring($image_p, $font_size, 5, 5, $text, $white);
imagejpeg($image_p, null, 80);
?>

Like I said before, everything works fine if I put the email processing + captcha verification code alone. Once I combine it with the horrible page code it does not work!

HELP!

bee80
10-14-2009, 07:03 PM
ok so you need to echo out the captcha image on the page it needs to be viewed

<?php echo "<img src=\"captcha.php\"> "; ?>

and you also need to pass along your session data so this will work

if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='') { }

do this by starting a session at the very top of the page

<?php
session_start();

/**
* validateManageComponent($input = component name)
*/
if ( is_file( dirname(__FILE__) . "/scripts/rvslib/component/rvsManageComponent.php") ) {
include( dirname(__FILE__) . "/scripts/rvslib/component/rvsManageComponent.php");
rvsManageComponent::validateManageComponent('Onlin e_Form');
} elseif ( is_file( dirname(dirname(__FILE__)) . "/.rvsitebuilder/rvsManageComponent.php") ) {
include( dirname(dirname(__FILE__)) . "/.rvsitebuilder/rvsManageComponent.php");
rvsManageComponent::validateManageComponent('Onlin e_Form');
}
?>

also in captcha.php add imagedestroy to the end

<?php
session_start();
$text = rand(10000,99999);
$_SESSION["vercode"] = $text;
$height = 25;
$width = 65;

$image_p = imagecreate($width, $height);
$black = imagecolorallocate($image_p, 0, 0, 0);
$white = imagecolorallocate($image_p, 255, 255, 255);
$font_size = 14;

imagestring($image_p, $font_size, 5, 5, $text, $white);
imagejpeg($image_p, null, 80);
////////////////////////////////
imagedestroy($image_p);
?>

bee80
10-14-2009, 07:05 PM
also in what way is it not working?

kremo5le
10-14-2009, 11:22 PM
Hey bee,

Just as I said the client did not want me to touch any good or bad code, it was exactly what happened. He decided to not to include the captcha and I ended up using just spry validations for each field and he was just thrilled thank God.

I appreciate your help enormously.


Have a good one!

k. :mrgreen: