PHP Code:
<?php
// First, make sure the form was posted from a browser.
// For basic web-forms, we don't care about anything
// other than requests from a browser:
if(!isset($_SERVER['HTTP_USER_AGENT'])){
die("Forbidden - You are not authorized to view this page");
exit;
}
// Make sure the form was indeed POST'ed:
// (requires your html form to use: action="post")
if(!$_SERVER['REQUEST_METHOD'] == "POST"){
die("Forbidden - You are not authorized to view this page");
exit;
}
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','Date');
pt_register('POST','Monthyear');
pt_register('POST','Notime');
pt_register('POST','Website');
pt_register('POST','Formname');
pt_register('POST','Firstname');
pt_register('POST','Lastname');
pt_register('POST','Companyname');
pt_register('POST','Email');
pt_register('POST','Telephone');
pt_register('POST','Market');
pt_register('POST','Comments');
pt_register('POST','Estimatedvalueequipment');
pt_register('POST','Signedupnewsletter');
pt_register('POST','visitorip');
$Comments = strip_tags($Comments);
$Comments = ereg_replace("<.*>","", $Comments);
$Comments = ereg_replace("http://*.","", $Comments);
$Comments = ereg_replace("[*.*]","", $Comments);
$Estimatedvalueequipment = str_replace("£", "", $Estimatedvalueequipment);
$Estimatedvalueequipment = str_replace(",", "", $Estimatedvalueequipment);
$Estimatedvalueequipment = str_replace(" ", "", $Estimatedvalueequipment);
$Estimatedvalueequipment = str_replace("$", "", $Estimatedvalueequipment);
$Estimatedvalueequipment = str_replace("/", "", $Estimatedvalueequipment);
$Estimatedvalueequipment = str_replace("?", "", $Estimatedvalueequipment);
$Estimatedvalueequipment = str_replace("", "", $Estimatedvalueequipment);
// Store current user's IP in a variable
$visitorip = $_SERVER['REMOTE_ADDR'];
$Date = date("d/m/Y H:i:s");
$Monthyear = date ("m/Y");
$Notime = date ("d/m/Y");
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Date: ".$Date."
Website: ".$Website."
Market: ".$Market."
Form name: ".$Formname."
First name: ".$Firstname."
Last name: ".$Lastname."
Company name: ".$Companyname."
Email: ".$Email."
Telephone: ".$Telephone."
Comments: ".$Comments."
Estimated value equipment: ".$Estimatedvalueequipment."
Signed up newsletter: ".$Signedupnewsletter."
Visitor IP: ".$visitorip."
";
$message = stripslashes($message);
//VALIDATION
if (eregi("\r",$Formname) || eregi("\n",$Formname) || eregi("Content-Type:",$Formname)){
die("SPAM Injection Error :(");
}
if ($Formname == "" || $Formname == "/r" || $Formname == "/n" || $Formname == " ") {
die();
}
if (preg_match("/@/i", "$Formname")) {
die("SPAM Injection Error :(");
} else {
//Ends here
mail("quotes@mydomain.com,marketing@mydomain.com","Quote Request : End user1 : ".$Market,$message,"From: ".$Email);
$link = mysql_connect("localhost","username","password");
mysql_select_db("dbname",$link);
$query="insert into webforms (Date,Monthyear,Notime,Website,Form_name,First_name,Last_name,Company_name,Email,Telephone,Comments,Estimated_value_equipment,Preferred_term_lease,Signedup_newsletter,visitorip,Market) values ('".$Date."','".$Monthyear."','".$Notime."','".$Website."','".$Formname."','".$Firstname."','".$Lastname."','".$Companyname."','".$Email."','".$Telephone."','".$Comments."','".$Estimatedvalueequipment."','".$Signedupnewsletter."','".$visitorip."','".$Market."')";
mysql_query($query);
header("Refresh: 0;url=../quotes/request_a_quote_thanks.html");
}
?><?php
}
?>
Thanks again for your assistance.
Bookmarks