//validate input include("../php/config.php"); include("../php/emailforms_config.php"); if(isset($_POST['FormType'])) { $error_message= array(); if(trim($_POST['Message'])=="") { $error_message[0]= "Type in some comment"; } if(trim($_POST['OptionalAdvertising']) == "Yes") { if(trim($_POST['FirstName']) == "") $error_message[1]= "Enter first name"; if(trim($_POST['LastName']) == "") $error_message[2] = "Enter last name"; if(trim($_POST['Phone']) == "" && trim($_POST['Email']) == "") $error_message[3] = "Enter phone or email"; }//if(@$_POST['OptionalAdvertising'] == "Yes") if(trim($_POST['ContactByEmail']) == "yes" && trim($_POST['Email']) == "") $error_message[4] = "Enter email"; if(trim($_POST['Email']) != "" && !IsEmailValid(trim(@$_POST['Email']))) { //check if email has a valid format of *@*.*[3] $error_message[4] = "Your email seems to be invalid."; }//if(@$_POST['Email']!="") if(@$_POST['ContactByMail']=="yes") { if(trim(@$_POST['Address1']) == "") { $error_message[6] = "Enter Address 1"; } if(trim(@$_POST['City']) == "") { $error_message[7] = "Enter City"; } if(trim(@$_POST['State']) == "") { $error_message[8] = "Enter State"; } if(trim(@$_POST['Zip']) == "") { $error_message[9] = "Enter Zip"; } else if(!is_numeric(@$_POST['Zip'])) { $error_message[9] = "Zip Must Be Numeric"; } }//if(@$_POST['ContactByMail']=="yes") { if(@$_POST['ContactByPhone']=="yes") { if(trim(@$_POST['Phone']) == "") { $error_message[5] = "Enter Phone"; } else if(!IsPhoneValid(@$_POST['Phone'])) { $error_message[5] = "Use format: xxx-xxx-xxxx."; } } if(trim(@$_POST['Phone']) !="" && !IsPhoneValid(trim(@$_POST['Phone']))) { //check if phone has a valid format of xxx-xxx-xxxx $error_message[5] = "Use format: xxx-xxx-xxxx."; } //if(@$_POST['Phone']!="") if(count(@$error_message) == 0) { //save to session //post to Controller for saving in database $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://$FormSubmitURL"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST); $date = curl_exec ($ch); //print $date; curl_close ($ch); Header("Location: ./thanx.html"); exit; } }//if ?>
|
|||||||||||||||||||||||||||||||