PDA

View Full Version : PHP captcha help


kona72
03-22-2006, 07:32 PM
Hi All,

I have configured a captcha script and had it working but added some fields in the form that i needed it to capture. Now after i have modified the mail tag it doesn't even want to display much less send.

Here is what i am dealing with (and have been for the last 2 days!)

$to = "curtis@trafick.net";


if (!isset($_POST['submit'])) {

showForm();

} else { //form submitted

$error = 0;


if(empty($_POST['firstname'])) {
$error = 1;
$errstr[] = "Please enter your First Name";
}

if(empty($_POST['lastname'])) {
$error = 1;
$errstr[] = "Please enter your Last Name";
}

if(empty($_POST['address'])) {
$error = 1;
$errstr[] = "Please enter your Address";
}

if(empty($_POST['city'])) {
$error = 1;
$errstr[] = "Please enter your City";
}

if(empty($_POST['postalcode'])) {
$error = 1;
$errstr[] = "Please enter your Postal Code";
}

if(empty($_POST['vehicle'])) {
$error = 1;
$errstr[] = "Please enter your Vehicle Make and Model";
}

if(!preg_match("/^(?:[\w\d]+\.?)+@(?:(?:[\w\d]\-?)+\.)+\w{2,4}$/", $_POST['email'])) {
$error = 1;
$errstr[] = "Please enter a valid email address";
}

if (empty($_POST['phone'])) {
$error = 1;
$errstr[] = "Please enter your Phone Number";
}

if(empty($_POST['imagetext'])) {
$error = 1;
$errstr[] = "Please validate the image code";
} else {
include "securimage.php";
$img = new securimage();
$valid = $img->check($_POST['imagetext']);

if(!$valid) {
$error = 1;
$errstr[] = "The code you entered was incorrect";
}
}

if ($error == 1) {
echo "<center>\n<font style=\"color: #FF0000\">\n";
foreach($errstr as $err) {
echo " " . $err . "\n";
}
echo "</font>\n</center>\n
\n\n";

showForm();

} else {
@mail($to, "Area Distributor Application" . $_POST['subject'],
"Application submitted \n On " . date("r") . "by, " . $_POST['firstname'] . " " . $_POST['lastname'] . " with email address " . $_POST['email'] .
" sent the following information with regards to the Area Distributor Application./n"
"\nFirst Name:" .
$_POST['firstname'] .
"\nLast Name: " . $_POST['lastname'] . , "From: " . $_POST['email']);

}
echo "<center>\n

<h3>Application Submitted</h3>

Thank you for your interest in The Flyer Force Edmonton. If your email requires a response then we will get back to you within 48 hours.



";

}

} //else submitted



function showForm()
{
$_POST['message'] = @htmlspecialchars(@$_POST['message']);

echo <<<EOD
<form method="POST">
<table class="dl" cellpadding="5" cellspacing="0" width="450" align="left">
<tr>
<td width="45%" align="left" class="body">*First Name</td>
<td width="55%" align="left" class="body"><input type="text" name="firstname" value="{$_POST['firstname']}" /></td>
</tr>
<tr>
<td class="body" align="left">*Last Name</td>
<td class="body" align="left"><input type="text" name="lastname" value="{$_POST['lastname']}" /></td>
</tr>
<tr>
<td class="body" align="left">*Address</td>
<td class="body" align="left"><input type="text" name="address" value="{$_POST['address']}" /></td>
</tr>
<tr>
<td class="body" align="left">*City</td>
<td class="body" align="left"><input type="text" name="city" value="{$_POST['city']}" /></td>
</tr>
<tr>
<td class="body" align="left">*Postal Code</td>
<td class="body" align="left"><input type="text" name="postalcode" value="{$_POST['postalcode']}" /></td>
</tr>
<tr>
<td class="body" align="left">*Vehicle make and model</td>
<td class="body" align="left"><input type="text" name="vehicle" value="{$_POST['vehicle']}" /></td>
</tr>
<tr>
<td class="body" align="left">minimum vehicle requirements: Reliable 3/4 or 1 ton extended van/cube van/truck </td>
</tr>
<tr>
<td class="body" align="left">*Email Address</td>
<td class="body" align="left"><input type="text" name="email" value="{$_POST['email']}" /></td>
</tr>
<tr>
<td class="body" align="left">Phone Number </td>
<td class="body" align="left"><input type="text" name="phone" value="{$_POST['phone']}" /></td>
</tr>
<tr>
<td class="body" align="center" colspan="2">securimage_show.php</td>
</tr>
<tr>
<td class="body" align="left">Please enter the code generated in the above image: </td>
<td class="body" align="left"><input type="text" name="imagetext" /></td>
</tr>
<tr>
<td class="body" align="center" colspan="2"><input type="submit" name="submit" value="Send Form" /></td>
</tr>
</table>
</form>
EOD;
}

?>
</td>
</tr>
</table>

Please Help!!!

Thanks in advance!!

kona72
03-23-2006, 08:54 PM
Ok... It's coming along but i am having some formating problems.



@mail($to, "Area Distributor Application Submission" . $_POST['subject'],
"Application received,\nOn " . date("r") . ", " . $_POST['firstname'] . " " . $_POST['lastname'] . "
" . $_POST['email'] .
" submitted the following application.\n
Address:". $_POST['city'] .
"City:". $_POST['city'] .
"Postal Code:". $_POST['postalcode'] .
"\n\n" . stripslashes($_POST['address']), "From: " . $_POST['email']);

echo "<center>\n<h3>Application Submitted</h3>
Thank you for your interest in The Flyer Force Edmonton.
If your email requires a response then we will get back to you within 48 hours.";

Output to email look slike this now.....


Application received,
On Wed, 22 Mar 2006 18:10:05 -0600, Curtis Rostad
crostad@sasktel.net submitted the following application.

Address:ReginaCity:ReginaPostal Code:S4S 0E3

4121 19th AVe

How do i get the different variable to display on different lines??

kona72
03-24-2006, 12:44 AM
Anyone??
I am really stuck here. I have been pouring over Ken's Handbook but cannot for the life of me come up with a solution....

Please Help!!