Contact Us
if (!isset($_POST['action'])) {
$action="none";
} ELSE {
$action=$_POST['action'];
}
if (isset($_POST['name'])) {
$name=mysql_escape_string($_POST['name']);
}
if (isset($_POST['liame'])) {
$liame=mysql_escape_string($_POST['liame']);
}
if (isset($_POST['phone'])) {
$phone=mysql_escape_string($_POST['phone']);
}
if (isset($_POST['zip'])) {
$zip=mysql_escape_string($_POST['zip']);
}
if (isset($_POST['comments'])) {
$comments=mysql_escape_string($_POST['comments']);
}
if (isset($_POST['category'])) {
$category=mysql_escape_string($_POST['category']);
}
if (isset($_POST['department'])) {
$department=mysql_escape_string($_POST['department']);
}
if (get_magic_quotes_gpc()) {
$comments = stripslashes( $comments );
}
if ($department == 'General') { $email = 'intake'; }
if ($department == 'HASC Intake') { $email = 'intake'; }
if ($department == 'After School Program') { $email = 'intake'; }
if ($department == 'Community Habilitiation') { $email = 'mwellerstein'; }
if ($department == 'Blanche Kahn Health Center') { $email = 'srosenfeld'; }
if ($department == 'Binuryni Parent Support Network') { $email = 'ebiener'; }
if ($department == 'Day Programs') { $email = 'senglard'; }
if ($department == 'Employment Opportunities') { $email = 'mfendrich'; }
if ($department == 'Medicaid Service Coordination') { $email = 'nwiesel'; }
if ($department == 'Residential Services') { $email = 'bdruker'; }
if ($department == 'Respite Services') { $email = 'asacks'; }
if ($department == 'Autism Program') { $email = 'intake'; }
if ($department == 'Vocational Opportunities') { $email = 'senglard'; }
if ($department == 'Volunteer Services') { $email = 'rbraunstein'; }
$emailto = $email.'@hasccenter.org,log@duvys.com';
//$comments=str_replace ("'", "", $comments);
//$comments=str_replace ('"', '', $comments);
if($_POST['starttime']){
$starttime=$_POST['starttime'];
$endtime = microtime();
$endarray = explode(" ", $endtime);
$endtime = $endarray[1] + $endarray[0];
$totaltime = $endtime - $starttime;
$totaltime = round($totaltime,5);
//echo "Total time: $totaltime";
}
$http_referrer = getenv( "HTTP_REFERER" );
$ip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
$http_agent = getenv ("HTTP_USER_AGENT");
$curDate = date("l, F j, Y, g:i a") ;
switch($action){
case 'insert':
if (eregi('http', $comments)) {
die ('
Sorry, we do not allow urls in the comment field.
Please go back to correct it.');
}
if(((($liame) && strstr($liame,"@") && strstr($liame,"."))||($RequireEmail=='0')) && ($totaltime>='2')){
if($InsertDB == 1) {
$newid = insert($name,$phone,$liame,$comments,$category,$department,$http_referrer,$ip,$http_agent);
}
sendEMail($emailto,$sitename,$subject,$CustomerEmail,$CustomerSubject,$CustomerMessage,$name,$phone,$liame,$comments,$category,$department,$http_referrer,$ip,$http_agent,$curDate,$newid);
message('

Thank you for contacting us.
A representative will get back to you shortly.');
}else{
echo '
There was an error submitting this form. Please contact our office. (Error code: TT-'.$totaltime.')
';
}
break;
default :
showFrm();
}
function showFrm()
{
?>
}
function insert($name,$phone,$liame,$comments,$category,$department,$http_referrer,$ip,$http_agent)
{
global $database_main,$main,$sql;
$comments=addslashes($comments);
$sql = "INSERT INTO `contact` (date,name,phone,liame,comments,category,department,http_referrer,ip)
VALUES (NOW(),'$name','$phone','$liame','$comments','$category','$department','$http_referrer','$ip')";
//message ($sql);
mysql_select_db($database_main, $main);
$id = mysql_query($sql);
$id = mysql_insert_id();
return $id;
}
function sendEmail($emailto,$sitename,$subject,$CustomerEmail,$CustomerSubject,$CustomerMessage,$name,$phone,$liame,$comments,$category,$department,$http_referrer,$ip,$http_agent,$curDate,$newid)
{
//$Comment=addslashes($Comment);
$comments = str_replace('\r', '
', $comments);
$comments = str_replace('\n', '
', $comments);
$comments = stripslashes( $comments );
if($InsertDB == 1) {
$newid = ' Reference # '.$newid;
}
$email_message = 'The following contact form has just been submitted from your site.
From: '.$name.'
Phone: '.$phone.'
Email: '.$liame.'
Comments: '.$comments.'
This message was sent at '.$curDate.' from: '.$http_referrer.' ref: '.$newid.' IP:'.$ip.' '.$http_agent.'
';
// echo $email_message;
$SentSuccess = mail($emailto, $subject, $email_message, "From: $name <$liame>");
if($CustomerEmail == 1) {
mail($liame, $CustomerSubject, $CustomerMessage, "From: $sitename <$emailto>");
}
if(!$SentSuccess) { die('
There was an error emailing this form. Please contact our office.
'); }
return;
}
function message($message)
{
echo "
$message
";
// Don't allow to refresh page
// $curLocation = $_SERVER['PHP_SELF'].'?action= ';
// header( "Location: $curLocation" );
}
?>