Skip to content

Instantly share code, notes, and snippets.

@arschmitz
Created November 10, 2010 15:57
Show Gist options
  • Save arschmitz/671025 to your computer and use it in GitHub Desktop.
Save arschmitz/671025 to your computer and use it in GitHub Desktop.
<?php
require( '/home/content/b/i/l/billdodgeweb/html/nav.php' );
?>
<div class="body_wrapper">
<br/>
<!-- InstanceBeginEditable name="content" -->
<div class="content_wrapper">
<?php
require('send_mail.php');
$require_string = "required";
form_top("contact_form", "http://www.billdodgeautogroup.com/parts/index_3.php");
head("1", "How can we get in touch with you?", "Contact Information");
contact_info($require_string);
run_mail("contact_form", "alex.schmitz@bdag.com", "contact", $require_string);
form_bottom();
?>
</div>
<!-- InstanceEndEditable -->
</div>
<?php
require( '/home/content/b/i/l/billdodgeweb/html/quicklinks.php' );
require( '/home/content/b/i/l/billdodgeweb/html/foot.php' );
?>
<?php
echo "<link rel=\"stylesheet\" href=\"http://www.billdodgeautogroup.com/form.css\" type=\"text/css\" />
<link rel=\"stylesheet\" href=\"/page_style_php.css\" type=\"text/css\"></link>";
function run_mail($form_name, $emailto, $cat1, &$require_string, $cat2="0", $cat3="0", $cat4="0"){
if(Trim(stripslashes($_POST['contact:name:first_displaylabel'])) != ""){
email($form_name, $emailto, $require_string, $cat1, $cat2 , $cat3 , $cat4);
}
if(Trim(stripslashes($_REQUEST['sucess'])) == "1") echo "thank you";
}
function contact_info(&$require_string){
text_input("contact:name:first","First Name: ", $require_string, "1", "15");
text_input("contact:name:last","Last Name: ", $require_string, "1", "15");
$preferred_contact = array("E-mail","Home Phone", "Day Phone", "Cell Phone", "Fax");
dropdown("contact:preferred", "Preferred Contact: ", $preferred_contact, "1");
text_input("contact:email", "E-mail: ", $require_string, "1");
text_input("contact:phone:home", "Home Phone: ", $require_string);
text_input("contact:phone:day", "Day Phone: ", $require_string);
text_input("contact:phone:cellphone", "Cellphone: ", $require_string);
text_input("contact:phone:fax", "Fax: ", $require_string);
text_input("contact:address:street", "Street Address: ", $require_string);
text_input("contact:address:city", "City: ", $require_string);
state();
text_input("contact:address:zip", "Zip Code: ", $require_string);
close_section();
}
function form_bottom(){
echo "<fieldset class=\"submitFieldset\" class=\"fieldset_container\"> \n
<div id=\"formSubmitButtonGroup\" class=\"fieldGroup\"> \n
<input type=\"image\" name=\"form_SubmitButton\" class=\"form_button\" id=\"orderButton\" src=\"http://assets.cobaltnitra.com/websites/websitesEar/websitesWebApp/common/images/leadForm_submit.png\" value=\"Submit\"> \n
</div> \n
</fieldset> \n
</div> \n
</div>
<div class=\"fieldsetBreak\"></div> \n
<div style=\"clear:both;\">&nbsp;</div> \n
</form> \n ";
}
function close_section(){
echo "</fieldset></fieldset>";
}
function form_top($form_name, $link, $form_width = ""){
echo "<form name=\"$form_name\" id=\"$form_name\" class=\"cobaltForm\" method=\"post\" action=\"$link\" style=\"width:".$form_width."px; \" novalidate> \n
<div class=\"heading\"> \n
<span class=\"required\">* Indicates required field </span> \n
</div> \n";
$validation_width = $form_width-70;
echo "<div id=\"validationAlert\" style=\"overflow:hidden; height:auto; width:".$validation_width."px; display:block;";
if(Trim(stripslashes($_REQUEST['error1'])) == "") echo "display:none;";
echo "\"> \n";
echo display_errors();
echo "</div> <br/><br/>\n";
}
function head($step, $text, $head_text, $width="", $id=""){
$width = $width-70;
echo "<div id=\"form_mainContainer\"> \n
<fieldset id=\"form_container_step".$step."\" class=\"fieldset_container\" style=\"display:block; *width:1%; *height:1%;\"> \n
<legend id=\"sectionGroup_0".$step."_legendText\" class=\"legend_container\" style=\" width:".$width."px; display:block; clear:both; \"><span>".$text."</span></legend> \n
<fieldset class=\"fieldset_section\" id=\"\"> \n
<legend class=\"legend_section\"> \n
<span> \n
$head_text \n
</span> \n
</legend> \n";
}
function state(){
$field = "contact:address:state";
$label = "State: ";
input_div($field, $label);
$state = array("AK","AL","AR","AS","AZ","CA","CO","CT","DC","DE","FL","FM","GA","GU","HI","IA","ID","IL","IN","KS","KY","LA","MA","ME","MD","MH","MI","MN","MO","MP","MS","MT","NC","ND","NE","NH","NJ","NM","NV","OH","OK","OR","PA","PR","RI","SC","SD","TN","TX","UT","VA","VI","VT","WA","WI","WV","WY");
echo "<select id=\"$field\" name=\"$field\" class=\"form_select\">";
$size = sizeof($state);
for($i = "0"; $i < $size; $i++){
echo "<option value=\"$state[$i]\"";
if($_REQUEST[$field] == "" && $state[$i] == "ME") echo "selected";
else echo selected($field,$state[$i]);
echo ">$state[$i]</option> \n";
}
echo "</select> \n </div> \n";
}
function input_div($field, $label, $required="0"){
echo "<div id=\"".$field."_div\" class=\"fieldGroup\"> \n";
echo "<input type=\"hidden\" name=\"".$field."_displaylabel\" value=\"$label\"> \n";
echo "<label for=\"$field\" class=\"label\">";
if($required == "1") echo "<span class=\"required\">*</span> ";
echo "$label </label> \n";
}
function text_input($field, $label, &$require_string, $required="0", $size="20"){
input_div($field, $label, $required);
echo "<input id=\"$field\" type=\"text\" name=\"$field\" value=\"";
echo value($field);
echo "\" ";
if($required == "1") {
echo red("$field");
$require_string .="|$field";
}
echo " size=\"$size\" class=\"form_textInput\" /> \n";
echo "</div> \n";
}
function dropdown($field, $label, $values, $required="0"){
input_div($field, $label, $required);
echo "<select id=\"$field\" name=\"$field\" class=\"form_select\">";
for($i=0; $i < sizeof($values); $i++){
echo "<option value=\"$values[$i]\"";
echo selected($field,$values[$i]);
echo ">$values[$i]</option> \n";
}
echo "</select> \n </div> \n";
}
function checked($field){
if(Trim(stripslashes($_REQUEST[$field])) != "") echo "checked";
}
function value($field){
echo Trim(stripslashes($_REQUEST[$field]));
}
function selected($field, $condition){
if(Trim(stripslashes($_REQUEST[$field])) == $condition) echo "selected";
}
function red($field){
if(Trim(stripslashes($_REQUEST[$field])) == "Please Complete This Field") echo "style=\"background-color:red;\"";
}
function display_errors(){
$error = Trim(stripslashes($_REQUEST['error1']));
if(Trim($error) != ""){
echo "You forgot to fill in the following sections: <br />";
for($i = "1"; $i <= "13"; $i++) {
$error = Trim(stripslashes($_REQUEST['error'.$i]));
if(Trim($error) != ""){
$error .= "<br/>";
echo "$error";
}
}
echo "Please fill in ALL required fields";
}
}
function validate( &$error_string, &$field, $field_label, &$error_count){
// echo "$error_count";
if ($field == "" || $field == "Please Complete This Field" || $field == " ") {
$error_count++;
$error_string .= "error".$error_count."=".urlencode($field_label)."&amp;";
$field = "Please Complete This Field";
//echo "$error_count";
}
}
function email_cat($category, &$Body){
$line = "0";
$Body .= "== ".strtoupper($category)." INFORMATION";
$Body .= "\n";
$Body .= "===============================================";
$Body .= "\n";
foreach ($_POST as $var => $value){
if(eregi($category,$var)){
if ($value == "on") $value = $var;
if ($line == "0"){
$Body .= $value.": ";
$line = "1";
}
else{
$Body .= $value."\n";
$line = "0";
}
}
}
$Body .= "\n";
$Body .= "\n";
}
function email($name, $EmailTo, $required="0", $cat1 = "0",$cat2 = "0", $cat3 = "0", $cat4 = "0"){
$error_count = "0";
$error = "<meta http-equiv=\"refresh\" content=\"0;URL=/parts/index_3.php?";
if($required != "0"){
foreach ($_POST as $var => $value){
if (eregi($required, $var)) validate($error, $value, $_POST[$var."_displaylabel"], $error_count);
$error .= $var."=".urlencode($value)."&amp;";
}
}
if ($error_count != "0") {
$error .= "\">";
print $error."fail";
exit;
}
$Subject = "$name Request Form (www.billdodgeautogroup.com)";
$Body .= "This email was sent from www.billdodgeautogroup.com. ";
$Body .= "\n";
$Body .= "The page used to send this email is $name Form. ";
$Body .= "\n";
$Body .= "\n";
$Body .= "\n";
if($cat1 != "0"){
email_cat("$cat1", $Body);
}
if($cat2 != "0"){
email_cat("$cat2", $Body);
}
if($cat3 != "0"){
email_cat("$cat3", $Body);
}
if($cat4 != "0"){
email_cat("$cat4", $Body);
}
// send email
$success = mail($EmailTo, $Subject, $Body, "From: ".$_POST['contact:email']);
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=/parts/index_3.php?sucess=1\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=/autorewards/error.html\">";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment