Hello,
I'm trying to validate specific fields in my PHP form, such as FirstName, LastName, etc. I've tried several techniques so far from various articles to confirm these fields and nothing seems to work at the moment. Here is the code:
<?php
$host = "xxxxxx";
$username = "xxxxxxx";
$password = "xxxxxxxx";
$database ="xxxxxxx";
$conn = mysql_connect ($host, $username, $password) or die ("could not connect");
$db = mysql_select_db($database, $conn) or die ("could not select DB");
$id=mysql_real_escape_string($_POST['id']); //This value has to be the same as in the HTML form file
$FirstName=mysql_real_escape_string($_POST['FirstName']); //This value has to be the same as in the HTML form file
$LastName=mysql_real_escape_string($_POST['LastName']); //This value has to be the same as in the HTML form file
$FirmName=mysql_real_escape_string($_POST['FirmName']); //This value has to be the same as in the HTML form file
$AttorneyName=mysql_real_escape_string($_POST['AttorneyName']); //This value has to be the same as in the HTML form file
$Phone=mysql_real_escape_string($_POST['Phone']);
$Email=mysql_real_escape_string($_POST['Email']);
$ProceedingMonth=mysql_real_escape_string($_POST['ProceedingMonth']);
$ProceedingDay=mysql_real_escape_string($_POST['ProceedingDay']);
$ProceedingYear=mysql_real_escape_string($_POST['ProceedingYear']);
$ProceedingCity=mysql_real_escape_string($_POST['ProceedingCity']);
$ProceedingState=mysql_real_escape_string($_POST['ProceedingState']);
$CaseCaption=mysql_real_escape_string($_POST['CaseCaption']);
$ProceedingType=mysql_real_escape_string($_POST['ProceedingType']);
$time=mysql_real_escape_string($_POST['time']);
$tzne=mysql_real_escape_string($_POST['tzne']);
$LengthOfDepo=mysql_real_escape_string($_POST['LengthOfDepo']);
$WitnessOrJudgeName=mysql_real_escape_string($_POST['WitnessOrJudgeName']);
$NeedVideo=mysql_real_escape_string($_POST['NeedVideo']);
$Interpreter=mysql_real_escape_string($_POST['NeedVideo']);
$SpecialInstructions=mysql_real_escape_string($_POST['SpecialInstructions']);
$evilblocker=mysql_real_escape_string($_POST['evilblocker']);
$answer="Accurate";
$promocde=mysql_real_escape_string($_POST['promocde']);
$promoanswer="xxxxxxx";
$syncpromo=mysql_real_escape_string($_POST['syncpromo']);
$correctanswer="Thank you order has been processed.";
$correctanswer2="You have entered a valid promo code please enjoy our gift to you.";
$wronganswer="You have typed in the wrong information in the Security Image field.";
$all= $send . $answer . $send2;
$promo="your promo code does not match a current promo offer";
//Mails the form to Accurate Court Reporting, Inc (to the production department).
$to = "scheduling@acrdepos.com";
$subject = "A client has ordered a Videographer/Court Reporter/VideoConferencing";
$message = "A client has placed an order here are the details."."\n" ."\n"."CLIENT INFORMATION:" ."\n"."\n". "SCHEDULING ATTORNEY: ".$AttorneyName ."\n". "FIRM NAME: ".$FirmName . "\n". "CONTACTS FIRST NAME: ".$FirstName ."\n". "CONTACTS LAST NAME: " .$LastName ."\n". "PHONE:" .$Phone ."\n". "EMAIL ADDRESS:" .$Email ."\n"."\n".
"CASE INFORMATION:" ."\n"."\n". "CASE CAPTION:".$CaseCaption ."\n"."DEPONENT:".$WitnessOrJudgeName ."\n"."DATE OF DEPOSITION:" .$ProceedingMonth." ".$ProceedingDay." ".$ProceedingYear ."\n"."TIME OF DEPOSITION:".$time." ,".$tzne ."\n"."ESTIMATED LENGTH OF DEPOSITION: ".$LengthOfDepo ."\n"."\n"."NUMBER OF ATTENDEES: ".$attendees ."\n"."\n"."LOCATION OF DEPOSITION: ".$acrlocal ."\n"."\n"."ADDRESS IF NOT AN ACR, INC. LOCATION: ".$OtherAddress ."\n"."NOTICE OF DEPOSITION SENT VIA: ".$NoticeDelivery ."\n"."\n".
"PRODUCTION INFORMATION:" ."\n"."\n". "TRANSCRIPT DELIVERY DATE: ".$TransDeliveryRequest ."\n". "TRANSCRIPT DELIVERY METHOD:".$TransDeliveryMethod ."\n"."\n".
"SPECIAL SERVICES NEEDED:" ."\n"."\n". "REALTIME NEEDED: ".$Reeltime ."\n". "VIDEOGRAPHER NEEDED: ".$NeedVideo ."\n". "INTERPRETER NEEDED: ".$Interpreter ."\n". "INTERPRETER LANGUAGE: ".$Language ."\n". "PROMO CODE: ".$promocde ."\n". "ADDITIONAL COMMENTS:".$SpecialInstructions;
$from = $_REQUEST['Email'];
$header1= "From: Accurate Court Reporting, Inc.";
$subject1 = "You have placed an order with Accurate Court Reporting, Inc.";
$autoreply = "You have placed an order with Accurate Court Reporting, Inc. here are the details."."\n" ."\n"."CLIENT INFORMATION:" ."\n"."\n". "SCHEDULING ATTORNEY: ".$AttorneyName ."\n". "FIRM NAME: ".$FirmName . "\n". "CONTACTS FIRST NAME: ".$FirstName ."\n". "CONTACTS LAST NAME: " .$LastName ."\n". "PHONE:" .$Phone ."\n". "EMAIL ADDRESS:" .$Email ."\n"."\n".
"CASE INFORMATION:" ."\n"."\n". "CASE CAPTION:".$CaseCaption ."\n"."DEPONENT:".$WitnessOrJudgeName ."\n"."DATE OF DEPOSITION:" .$ProceedingMonth." ".$ProceedingDay." ".$ProceedingYear ."\n"."TIME OF DEPOSITION:".$time." ,".$tzne ."\n"."ESTIMATED LENGTH OF DEPOSITION: ".$LengthOfDepo ."\n"."\n"."NUMBER OF ATTENDEES: ".$attendees ."\n"."\n"."LOCATION OF DEPOSITION: ".$acrlocal."\n"."\n"."ADDRESS IF NOT AN ACR, INC. LOCATION: ".$OtherAddress ."\n"."NOTICE OF DEPOSITION SENT VIA: ".$NoticeDelivery ."\n"."\n".
"PRODUCTION INFORMATION:" ."\n"."\n". "TRANSCRIPT DELIVERY DATE: ".$TransDeliveryRequest ."\n". "TRANSCRIPT DELIVERY METHOD:".$TransDeliveryMethod ."\n"."\n".
"SPECIAL SERVICES NEEDED:" ."\n"."\n". "REALTIME NEEDED: ".$Reeltime ."\n". "VIDEOGRAPHER NEEDED: ".$NeedVideo ."\n". "INTERPRETER NEEDED: ".$Interpreter ."\n". "INTERPRETER LANGUAGE: ".$Language ."\n". "PROMO CODE: ".$promocde."\n". "ADDITIONAL COMMENTS:".$SpecialInstructions;
$sql="INSERT INTO ACRSchedule (AttorneyName,FirmName,FirstName,LastName,Phone,Email,CaseCaption,WitnessOrJudgeName,ProceedingMonth,ProceedingDay,ProceedingYear,time,tzne,LengthOfDepo,attendees,acrlocal,OtherAddress,NoticeDelivery,TransDeliveryRequest,TransDeliveryMethod,Reeltime,NeedVideo,Interpreter,Language,promocde,SpecialInstructions,evilblocker,syncpromo,hereabt,other) VALUES ('$AttorneyName','$FirmName','$FirstName','$LastName','$Phone','$Email','$CaseCaption','$WitnessOrJudgeName','$ProceedingMonth','$ProceedingDay','$ProceedingYear','$time','$tzne','$LengthOfDepo','$attendees','$acrlocal','$OtherAddress','$NoticeDelivery','$TransDeliveryRequest','$TransDeliveryMethod','$Reeltime','$NeedVideo','$Interpreter','$Language','$promocde','$SpecialInstructions','$evilblocker','$syncpromo','$hereabt','$other')";
//echo $sql;
if (!mysql_query($sql,$conn)) {
die('Error: ' . mysql_error());
}
if ($promocde == "$promoanswer")
{ echo $correctanswer2;
}
if ($evilblocker == "$all")
{echo $correctanswer;
$send = mail($to,$subject,$message);
$send2 = mail($from,$header1,$subject1,$autoreply);
}
else
{echo $wronganswer; }
mysql_close($conn);
?>
I know the code is quite overwhelming. Any help is appreciated.
Thanks