Forum Moderators: coopster
Not sure where i went wrong
Here is the code from my form
<?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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Cat & Dog Tag Renewal Form</title>
<script language="javascript" type="text/javascript">
<!--
//<![CDATA[
var tl_loc0=(window.location.protocol == "https:")? "https://secure.example.net/trustlogo/javascript/trustlogo.js" :
"http://www.example.com/trustlogo/javascript/trustlogo.js";
document.writeln('<scr' + 'ipt language="JavaScript" src="'+tl_loc0+'" type="text\/javascript">' + '<\/scr' + 'ipt>');
//]]>
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 ¦¦ p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min ¦¦ max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
</head>
<body topmargin ="0" leftmargin="0" marginwidth="0" marginheight="0" onLoad="createExpiry();">
<p><img border="0" src="images/header.jpg" width="675" height="119"></p>
<table border="0" width="800" cellspacing="0" cellpadding="0">
<tr>
<td width="3%"></td>
<td width="97%">
<?php
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$me = $_SERVER['PHP_SELF'];
?>
<form name="form1" method="post"
action="<?php echo $me;?>">
FORM HERE
<p>Enter text shown below:</p>
<p><img src="./?<?php echo session_name()?>=<?php echo session_id()?>"></p>
<p><input type="text" name="keystring"></p>
<input name="B1" type="submit" onclick="MM_validateForm('ID_Number','','R','Surname','','R','Given_Name', '','R','Email_Address','','RisEmail','Address','','R','Municipality','','R', 'Province','','R','Postal_Code','','R','Phone_Home','','R','CreditCardName','', 'R','CardNumber','','RisNum','CardNumber1','','RisNum','CardNumber2','', 'RisNum', 'CardNumber3','','RisNum','Amount_Paid','','R','vet_clinic_name','','R', 'Animal1_Name','','R');return document.MM_returnValue" value="Submit">
<input type="reset" value="Reset" name="B2">
</p>
</form><?php
if(count($_POST)>0){
if(isset($_SESSION['captcha_keystring']) && $_SESSION['captcha_keystring'] == $_POST['keystring']){
echo "Correct";
}else{
echo "Wrong";
}
}
unset($_SESSION['captcha_keystring']);
?>
</table>
<?php
} else {
error_reporting(0);
$recipient = 'contact@example.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 (800)555-1212
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 #: #*$!X-#*$!X-#*$!X-$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 [php.net...]
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@example.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 (800)555-1212
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.
}
}
?>
<p>
<!-- Seal verification code START --> <!-- Seal verification code END --></p>
</body>
</html>
[edited by: dreamcatcher at 12:40 am (utc) on Dec. 16, 2009]
[edited by: coopster at 4:45 am (utc) on Dec. 17, 2009]
[edit reason] Fixed side scroll and removed specifics [/edit]
you are not assigning any value to this session variable!
i cant see the part where you are generating the keystring! sorry i have not read the whole code as it is little long
you might want to take another look at your code and check that you are first creating the captcha then assigning it to session variable and then then check whether it equals to $_POST['keystring'] or not then unset it