Log in

View Full Version : Implement CAPTCHA in php_self file



justspiffy
14 Dec 2009, 03:30 PM
Hey everyone,

I am new to php, dont know to much, just how to make a form here and there. I have a question im hoping someone can help me with.

Does anyone know how to make CAPTCHA work in a php_self file?
I have made a form which works well, but everytime i try and add a CAPTCHA to it, it never works. Anyone have any experience in this that could help me out??
Thanks





<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$me = $_SERVER['PHP_SELF'];

?>


<form name="form1" method="post"
action="<?php echo $me;?>">

FORM HERE (TOO LONG TO INCLUDE)

</form>


<?php
} else {
error_reporting(0);
$recipient = 'contact@justspiffy.ca';
$Num_ID = stripslashes($_POST['ID_Number']);
$confirmation = md5($ID_Number . time());
$First_Name = stripslashes($_POST['Surname']);
$Last_Name = stripslashes($_POST['Given_name']);
$Email_Address = stripslashes($_POST['Email_Address']);
$Change_Con = stripslashes($_POST['Contact_Change']);
$Curr_Addy = stripslashes($_POST['Address']);
$Curr_Municipality = stripslashes($_POST['Municipality']);
$Curr_Province = stripslashes($_POST['Province']);
$PostalCode = stripslashes($_POST['Postal_Code']);
$Curr_Home = stripslashes($_POST['Phone_Home']);
$Curr_Work = stripslashes($_POST['Phone_Work']);
$Work_Ext = stripslashes($_POST['Phone_Work_Extension']);
$Cred_Type = stripslashes($_POST['Card_Type']);
$Curr_Card_Name = stripslashes($_POST['CreditCardName']);
$Curr_Card_Num = stripslashes($_POST['CardNumber']);
$Curr_Card_Num1 = stripslashes($_POST['CardNumber1']);
$Curr_Card_Num2 = stripslashes($_POST['CardNumber2']);
$Curr_Card_Num3 = stripslashes($_POST['CardNumber3']);
$Month_Exp = stripslashes($_POST['Expiry_Month']);
$Year_Exp = stripslashes($_POST['Expiry_Year']);
$Paid_Amo = stripslashes($_POST['Amount_Paid']);
$Name_Vet = stripslashes($_POST['vet_clinic_name']);
$Name_Ani1 = stripslashes($_POST['Animal1_Name']);
$Rab_Ani1_Mon = stripslashes($_POST['Rabies_Month_Animal1']);
$Rab_Ani1_Year = stripslashes($_POST['Rabies_Year_Animal1']);
$Name_Ani2 = stripslashes($_POST['Animal2_Name']);
$Rab_Ani2_Mon = stripslashes($_POST['Rabies_Month_Animal2']);
$Rab_Ani2_Year = stripslashes($_POST['Rabies_Year_Animal2']);
$Name_Ani3 = stripslashes($_POST['Animal3_Name']);
$Rab_Ani3_Mon = stripslashes($_POST['Rabies_Month_Animal3']);
$Rab_Ani3_Year = stripslashes($_POST['Rabies_Year_Animal3']);
$Cat_Dog = stripslashes($_POST['DogOrCat']);
$Comment = stripslashes($_POST['Notes']);

$sendto = $_POST['Email_Address'];
$headers = "From: $recipient\r\n\r\n";
$subject = "Licence Renewal Request $confirmation\n";
$message = "Thank you for registering your pet with London Animal Care Centre.\n
Please keep this email as proof of your application for your
dog licence or cat identification tag.

Your confirmation Id is $confirmation\n

If you have any questions or concerns please call (519)685-1330
and have your confirmation id available.\n
Please allow 3 to 6 weeks for processing and delivery of your tags.\n

ID #: $Num_ID\r\n
Name: $First_Name $Last_Name\r\n
E-Mail Address: $Email_Address\r\n
Have you had a change in address or phone number over the last year?: $Change_Con\r\n
Address: $Curr_Addy\r\n
Municipality: $Curr_Municipality\r\n
Province: $Curr_Province\r\n
Postal Code: $PostalCode\r\n
Phone # - Home: $Curr_Home\r\n
Phone # - Work: $Curr_Work\r\n
Work Ext: $Work_Ext\r\n
Card Type: $Cred_Type\r\n
Name of Cardholder: $Curr_Card_Name\r\n
Card #: XXXX-XXXX-XXXX-$Curr_Card_Num3\r\n
Expiry Date: $Month_Exp $Year_Exp\r\n
Please indicate amount to be paid: $Paid_Amo\r\n
Veterinarian Clinic Name: $Name_Vet\r\n
Name of First Animal: $Name_Ani1\r\n
Month and Year of Vaccination: $Rab_Ani1_Mon $Rab_Ani1_Year\r\n
Name of Second Animal: $Name_Ani2\r\n
Month and Year of Vaccination: $Rab_Ani2_Mon $Rab_Ani2_Year\r\n
Name of Third Animal: $Name_Ani3\r\n
Month and Year of Vaccination: $Rab_Ani3_Mon $Rab_Ani3_Year\r\n
Breed Certification: $Cat_Dog\r\n
Notes: $Comment\r\n
";
// Send mail to customer, refer to http://php.net/manual/en/function.mail.php
mail($sendto, $subject, $message, $headers);
if (!mail) {
echo "Message failed to send, please notify our Web Team.";
} else {
echo nl2br ("<center><br><br><br><br><br><br><br><br><br><br>Thank you. Your request has been sent and we will contact you shortly.<br><br><br><br><br><br><br><br><br><br></center>");
}
// Send mail to company
$to = "contact@justspiffy.ca"; // who gets this one?
$message = "Thank you for registering your pet with London Animal Care Centre.\n
Please keep this email as proof of your application for your
dog licence or cat identification tag.<br />

Your confirmation Id is $confirmation\n

If you have any questions or concerns please call (519)685-1330
and have your confirmation id available.\n
Please allow 3 to 6 weeks for processing and delivery of your tags.\n

ID #: $Num_ID\r\n
Name: $First_Name $Last_Name\r\n
E-Mail Address: $Email_Address\r\n
Have you had a change in address or phone number over the last year?: $Change_Con\r\n
Address: $Curr_Addy\r\n
Municipality: $Curr_Municipality\r\n
Province: $Curr_Province\r\n
Postal Code: $PostalCode\r\n
Phone # - Home: $Curr_Home\r\n
Phone # - Work: $Curr_Work\r\n
Work Ext: $Work_Ext\r\n
Card Type: $Cred_Type\r\n
Name of Cardholder: $Curr_Card_Name\r\n
Card #: $Curr_Card_Num $Curr_Card_Num1 $Curr_Card_Num2 $Curr_Card_Num3\r\n
Expiry Date: $Month_Exp $Year_Exp\r\n
Please indicate amount to be paid: $Paid_Amo\r\n
Veterinarian Clinic Name: $Name_Vet\r\n
Name of First Animal: $Name_Ani1\r\n
Month and Year of Vaccination: $Rab_Ani1_Mon $Rab_Ani1_Year\r\n
Name of Second Animal: $Name_Ani2\r\n
Month and Year of Vaccination: $Rab_Ani2_Mon $Rab_Ani2_Year\r\n
Name of Third Animal: $Name_Ani3\r\n
Month and Year of Vaccination: $Rab_Ani3_Mon $Rab_Ani3_Year\r\n
Breed Certification: $Cat_Dog\r\n
Notes: $Comment\r\n
";
mail($to, $subject, $message, $headers);
if (!mail) {
echo "Message failed to send. Please notify our Web Team.";
} else {
// something here to notify the web team if it fails.
}
}
?>