<html>
<head>
</head>
<body>
<?php
/ grabs the POST variables and puts them into variables that we can use /
$firstName=$POST['firstName'];
$lastName=$POST['lastName'];
$company=$POST['company'];
$email=$POST['email'];
$website=$POST['website'];
$countryCode=$POST['countryCode'];
$phone=$POST['phone'];
$phoneExt=$POST['phoneExt'];
$mobile=$POST['mobile'];
$fax=$POST['fax'];
$address=$POST['address'];
$city=$POST['city'];
$state=$POST['state'];
$country=$POST['country'];
$zipCode=$POST['zipCode'];
$heardAbout=$POST['heardAbout'];
$inquiring=$_POST['inquiring'];
//---------VALIDATION-------->
if($firstName){//----> CHECK input
}
else{
$error.="Please, go back and fill out your first name<br>\n";//----> ERROR if no input
}
if($lastName){//----> CHECK input
}
else{
$error.="Please, go back and fill out your last name<br>\n";//----> ERROR if no input
}
if($email){//----> CHECK input
}
else{
$error.="Please, go back and fill out your e-mail address<br>\n";//----> ERROR if no input
}
if($phone){//----> CHECK input
}
else{
$error.="Please, go back and fill out your phone number<br>\n";//----> ERROR if no input
}
if($address){//----> CHECK input
}
else{
$error.="Please, go back and fill out your mailing address<br>\n";//----> ERROR if no input
}
if($city){//----> CHECK input
}
else{
$error.="Please, go back and fill out your city name<br>\n";//----> ERROR if no input
}
if($zipCode){//----> CHECK input
}
else{
$error.="Please, go back and fill out your zip code<br>\n";//----> ERROR if no input
}
//-------->ERROR FREE??
if($error==""){
echo "Thank you for inquiring about us! A receipt of your submission will be e-mailed to you almost immediately.";
//----------------------------------
$mailContent="--------CONTACT--------\n"
."First Name: ".$firstName."\n"
."Last Name: ".$lastName."\n"
."Company: ".$company."\n"
."E-mail: ".$email."\n"
."Website: ".$website."\n\n--------PHONE--------\n"
."Phone: ".$countryCode." ".$phone."\n"
."Extension: ".$phoneExt."\n"
."Fax: ".$fax."\n"
."Mobile: ".$mobile."\n\n--------ADDRESS--------\n"
."Street Address: ".$address."\n"
."City: ".$city."\n"
."State: ".$state."\n"
."Country: ".$country."\n"
."Zip Code: ".$zipCode."\n\n--------INFO--------\n"
."Where did you hear about us? ".$heardAbout."\n"
."Inquiring About: ".$inquiring."\n"
//----------------------------------
$toAddress="kamaldeep.singh@religare.in"; / change this! /
$subject="MyWebSite.com's Products"; / change this! /
$recipientSubject="MyWebSite.com's Contact Form"; / change this! /
$receiptMessage = "Thank you ".$firstName." for inquiring about MyWebSite.com's Products!\n\n\nHere is what you submitted to us:\n\n"
// ."--------CONTACT--------\n"
."First Name: ".$firstName."\n"
."Last Name: ".$lastName."\n"
."Company: ".$company."\n"
."E-mail: ".$email."\n"
."Website: ".$website."\n\n--------PHONE--------\n"
."Phone: ".$countryCode." ".$phone."\n"
."Extension: ".$phoneExt."\n"
."Fax: ".$fax."\n"
."Mobile: ".$mobile."\n\n--------ADDRESS--------\n"
."Street Address: ".$address."\n"
."City: ".$city."\n"
."State: ".$state."\n"
."Country: ".$country."\n"
."Zip Code: ".$zipCode."\n\n--------INFO--------\n"
."Where did you hear about us? ".$heardAbout."\n"
."Inquiring About: ".$inquiring."\n"
//----------------------------------
mail($email, $subject, $receiptMessage,"From:$toAddress");
//----------------------------------
mail($toAddress,$recipientSubject,$mailContent,"From:$email");
--->echo $mailContent;
//////////////////////////////////////// CONNECT TO MYSQL DB ////////////////////
// OPEN CONNECTION --->
$connection=mysql_connect("localhost","root", "") or die("Unable to connect!"); / change this! /
mysql_select_db("hukumnama_contact") or die("Unable to select database!"); / change this! /
// EXECUTE QUERY --->
$query="INSERT INTO generalContact (
firstName,
lastName,
company,
email,
website,
countryCode,
phone,
phoneExt,
mobile,
fax,
address,
city,
state,
country,
zipCode,
heardAbout,
inquiringOn)
VALUES(
'".$firstName."',
'".$lastName."',
'".$company."',
'".$email."',
'".$website."',
'".$countryCode."',
'".$phone."',
'".$phoneExt."',
'".$mobile."',
'".$fax."',
'".$address."',
'".$city."',
'".$state."',
'".$country."',
'".$zipCode."',
'".$heardAbout."',
'".$inquiring."')";
//////----->
$result=mysql_query($query) or die("Error in query:".mysql_error());
//if ($result)
//echo mysql_affected_rows()." row inserted into the database effectively.";
// CLOSE CONNECTION --->
mysql_close($connection);
///////////////////////////////////////////////////////////////////////////////////
}
else{
print "Sorry, but the form cannot be sent until the fields indicated are filled out completely - <br>\n";
print "$error<br>\n";
print "<br>\n";
print "<br>\n";
print "Please use your \"Back\" button to return to the form to correct the omissions. Thank you.<br>\n";
}
?>
</body>
</html>