
|
|
Contact
Thank you for getting in contact with us!Your request has been sent and you'll be contacted as soon as possible.";
// form fields
/*
every form field is an array consisting of 6 elements:
1) field caption
2) field name
3) field type: line, field, radio, select, checkbox, multiselect, divider
4) additional info: if field type is
- 'radio' this field contains the radio captions/values like so: {caption1|value1} {caption2|value2} {caption3|value3}...
- 'select' this field contains the radio captions/values like so: {caption1|value1} {caption2|value2} {caption3|value3}...
- 'email' the field value must be a valid emailaddress
- 'checkbox' this field contains the radio captions/values like so: {caption1|value1} {caption2|value2} {caption3|value3}...
- 'multiselect' this field contains the radio captions/values like so: {caption1|value1} {caption2|value2} {caption3|value3}...
- 'divider' -> you can specify something like ' ' in the caption field
- 'field' this values optional defines a max chars number
5) mandatory ('*') or not ('')
6) error message if empty on submit and set to mandatory previously
*/
$fields[] = array("Company", "company", "line", "", "", "");
$fields[] = array("Name", "name", "line", "", "*", "Please enter a name");
$fields[] = array("Address", "address", "line", "", "", "");
$fields[] = array("Zip/City", "city", "line", "", "", "");
$fields[] = array("Phone", "phone", "line", "", "*", "Please enter a phone number");
$fields[] = array("Email", "email", "line", "email", "*", "Please enter a valid email address");
$fields[] = array("Reply by", "replyby", "radio", "{Email|by email}{Phone|by phone}", "*", "Please select a reply mode");
//$fields[] = array("Income", "income", "select", "{-- please choose --|}{more than $30'000|30000}{more than $50'000|50000}{more than $70'000|70000}", "*", "Please select your income");
//$fields[] = array(" ", "", "divider", "", "", "");
//$fields[] = array("Interests", "interests", "checkbox", "{Fishing}{Cars & Bikes|cars}{Music|music/sounds}{Cultures}", "*", "Please choose at least one interest");
//$fields[] = array("Interests 2", "interests_2", "multiselect", "{Fishing}{Cars & Bikes|cars}{Music|music/sounds}{Cultures}", "*", "Please choose at least one interest 2");
$fields[] = array(" ", "", "divider", "", "", "");
$fields[] = array("Request", "request", "field", "", "*", "Please enter a request");
$fields[] = array("Limited Text", "limited", "field", 250, "*", "Please enter a limited text");
// ################ END CONFIG ##########################################################
// #######################################################################################
$version = "1.5";
$errorPointer = ($posError == "above") ? "↓ " : "↑ ";
function spaces($num, $fill=" "){
$foo="";
for ($i=0; $i<$num; $i++) $foo.=$fill;
return $foo;
}
function isValidEmail($addr){
if(eregi("^[a-z0-9]+([_.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+\\.[a-z]{2,4}$", $addr))
return true;
else
return false;
}
function jsCharCount(){
if ($GLOBALS['cfCharCountFunc'] != 1){
$html = "\n";
$GLOBALS['cfCharCountFunc'] = 1;
return $html;
}
}
// start form evaluation
unset($error);
if ($_REQUEST['do']=="send"){
$error = false;
$fromAddress = "";
$message = "";
foreach ($fields as $field){
if ($field[4] == "*"){
if ($field[3] == "email"){
if (!isValidEmail($_REQUEST[$field[1]])) $error[$field[1]] = $field[5];
}else{
if ($_REQUEST[$field[1]] == "" || $_REQUEST[$field[1]] == " " || $_REQUEST[$field[1]] == " ") $error[$field[1]] = $field[5];
}
}
}
if ($error === false){
$message = $emailSubject." \n";
for ($i = 0; $i < strlen($emailSubject); $i++) $message .= "*";
$message .= " \n\n$msgDate:".spaces($msgIndent-strlen($msgDate)).date($dateFormat);
foreach ($fields as $field){
if ($field[2] == "divider"){
$message .= "\n-----------------------------------";
}else{
$message .= "\n".$field[0].":".spaces($msgIndent-strlen($field[0]));
if ($field[3] == "email"){
$message .= "mailto:".$_REQUEST[$field[1]];
$fromAddress = "From: ".$_REQUEST[$field[1]];
}else if ($field[2] == "checkbox" || $field[2] == "multiselect"){
$multi = "";
foreach ($_REQUEST[$field[1]] as $val){
$divider = ($multi != "") ? ", " : "";
$multi .= (isset($val) && $val != "") ? $divider.$val : "";
}
$message .= $multi;
$message = htmlentities($message);
}else $message .= $_REQUEST[$field[1]];
}
$message .= " ";
}
mail($targetAddress, $emailSubject, $message, $fromAddress);
//echo "$message ";
echo $txtThankyou;
}
}
if ($error!==false){
$html = "";
// draw form
$html .= "\n\n \n\n";
$html .= "\n";
$html .= "\n \n\n";
echo $html;
}
/*
######################### END Contact Form ##########################
#####################################################################
*/
?>
|
|