|
if ($page_header != "home") { ?>
}?>
if (isset($_POST['submit']))
{
require_once('recaptchalib.php');
$privatekey = "6LdOcMUSAAAAAAtcvUXUsjo0B84VtXmgOi_wejKl";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again. Back " .
"(reCAPTCHA said: " . $resp->error . ")");
}
}
require_once('../../includes/DbConnector.php');
require_once('../../includes/Validator.php');
// Create an object (instance) of the DbConnector and Validator
$connector = new DbConnector();
$validator = new Validator();
if (isset($_POST['submit']))
{
//select coordinator email from study
$study_qry = $connector->query('Select ID, SummaryTitle, CordEmail, ProtacallNum from Studies where ID="'.$HTTP_POST_VARS[Study].'"');
$s = $connector->fetchArray($study_qry);
$coord_email = $s['CordEmail'];
$studyname = $s['SummaryTitle'];
$protacallNum = $s['ProtacallNum'];
//email volunteer form and input into database
$to = "research@aactx.com";
$to2 = "shaunta@slkwebdesigns.com";
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Volunteer Form";
$fields = array();
$fields{"Name"} = "Name";
$fields{"Address"} = "Address";
$fields{"City"} = "City";
$fields{"State"} = "State";
$fields{"Zip"} = "Zip";
$fields{"HPhone"} = "Home Phone";
$fields{"WPhone"} = "Work Phone";
$fields{"CPhone"} = "Cell Phone";
$fields{"Email"} = "Email";
$fields{"ContactMethod"} = "Best Contact Method";
$fields{"BestTime"} = "Best Time";
//$fields{"YAddData"} = "Add to database";
//$fields{"NAddData"} = "Do not add to database";
//$fields{"NContact"} = "Wants to be contacted";
$insertQuery = "INSERT INTO Volunteer (Name, Address, City, State, Zip, HmPhone, WkPhone, CellPhone, Email, ".
" Method, Time, StudyID, StudyName, Interest, YData, NData, YContact, Date) VALUES (".
"'".$HTTP_POST_VARS['Name']."', ".
"'".$HTTP_POST_VARS['Address']."', ".
"'".$HTTP_POST_VARS['City']."', ".
"'".$HTTP_POST_VARS['State']."', ".
"'".$HTTP_POST_VARS['Zip']."', ".
"'".$HTTP_POST_VARS['HPhone']."', ".
"'".$HTTP_POST_VARS['WPhone']."', ".
"'".$HTTP_POST_VARS['CPhone']."', ".
"'".$HTTP_POST_VARS['Email']."', ".
"'".$HTTP_POST_VARS['ContactMethod']."', ".
"'".$HTTP_POST_VARS['BestTime']."', ".
"'".$HTTP_POST_VARS['Study']."', ".
"'".$studyname."', ".
"'".$HTTP_POST_VARS['Interest']."', ".
"'".$HTTP_POST_VARS['YAddData']."', ".
"'".$HTTP_POST_VARS['NAddData']."', ".
"'".$HTTP_POST_VARS['YContact']."', ".
"now())";
//print $insertQuery;
// Save the form data into the database
if ($result = $connector->query($insertQuery)){
// It worked, give confirmation
}else{
// It hasn't worked so stop. Better error handling code would be good here!
// exit('Sorry, there was an error saving to the database '.$upload_msg.'');
//print "Error inserting into database";
}
$body = "Study Volunteer Request:\n\n";
$body .= "Protocal Number: ";
$body .= $protacallNum;
$body .= "\n";
$body .= "Volunteer for Study: ";
$body .= $studyname;
$body .= "\n\n";
foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
if ($HTTP_POST_VARS['YAddData'] == '1')
{
$AddToDB = "Yes";
}
else
{
$AddToDB = "No";
}
if ($HTTP_POST_VARS['NAddData'] == '1')
{
$NoAddDB = "Yes";
}
else
{
$NoAddDB = "No";
}
if ($HTTP_POST_VARS['NContact'] == '1')
{
$WntContact = "Yes";
}
else
{
$WntContact = "No";
}
$body .= "\t\t Add to database: ";
$body .= $AddToDB;
$body .= "\n";
$body .= "\t\t Do not add to database: ";
$body .= $NoAddDB;
$body .= "\n";
$body .= "\t\t Wants to be contacted: ";
$body .= $WntContact;
$body .= "\n\n";
//$headers2 = "From: info@aactx.com";
//$subject2 = "Thank you for contacting us";
//$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com";
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '')
{
print "You have not entered a name, please go back and try again";
}
else {
$send = mail($to, $subject, $body, $headers);
$send3 = mail($to2, $subject, $body, $headers);
if ($cordemail != "")
{
$send2 = mail($cord_email, $subject, $body, $headers);
if ($send2)
{
//sent message
}
}
if($send3)
{
}
if($send)
{
print "Thank you for your volunteer information.";
$hide_form = 1;
}
else
{
print "We encountered an error sending your mail, please notify webmaster@slkwebdesigns.com";
$hide_form = 0;
}
}
}
}
if ($HTTP_GET_VARS[studyid])
{
//select study from database
$studyid = $HTTP_GET_VARS[studyid];
if ( $validator->validateNumber($studyid, 'Study Id'))
{
//valid number
$chked_studyid = $studyid;
//select coordinator email from study
$email_qry = $connector->query('Select ID, SummaryTitle, CordEmail from Studies where ID="'.$chked_studyid.'"');
$e = $connector->fetchArray($email_qry);
$coord_email = $e['CordEmail'];
$studyname = $e['SummaryTitle'];
}
}
if ($hide_form != 1)
{
echo '';
}
?> |