Athena-WFI Consortium Meeting20-22 November 2018, Lisboa, Portugal
die();
/*
* END
*/
require_once($_SERVER['DOCUMENT_ROOT'] . "/../includes/smtp.php");
$tablename=$confAcronym . "_reg";
// Criar o objecto
$firstname = isset($_POST['firstname']) ? $_POST['firstname'] : NULL;
$lastname = isset($_POST['lastname']) ? $_POST['lastname'] : NULL;
$email = isset($_POST['email_reg']) ? $_POST['email_reg'] : NULL;
$affiliation = isset($_POST['affiliation']) ? $_POST['affiliation'] : NULL;
$food = isset($_POST['food']) ? $_POST['food'] : NULL;
$firstname = trim($firstname);
$lastname = trim($lastname);
$email = trim($email);
$affiliation = trim($affiliation);
$checkBoxDinner = isset($_POST['checkBoxDinner']) ? 1 : NULL;
$food = trim($food);
$checkBoxPrivacy = isset($_POST['checkBoxPrivacy']) ? $_POST['checkBoxPrivacy'] : NULL;
$flag_done = isset($_POST['flag_done']) ? $_POST['flag_done'] : NULL;
$double = NULL;
if (isset($_POST['submit']) && $_POST['submit']) {
// Verificação dos resultados
$firstnameEmpty = !$firstname ? 1 : NULL;
$lastnameEmpty = !$lastname ? 1 : NULL;
$emailEmpty = !$email ? 1 : NULL;
$affiliationEmpty = !$affiliation ? 1 : NULL;
$email=strtolower($email);
$query = "SELECT id FROM `$tablename` WHERE email = '$email'";
$emailVerify = mysql_num_rows(mysql_query($query));
$checkBoxPrivacyEmpty = !isset($_POST['checkBoxPrivacy']) ? 1 : NULL;
$emailError= !ereg("[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]", $email) ? 1: NULL;
$firstname_db = mysql_real_escape_string($firstname);
$lastname_db = mysql_real_escape_string($lastname);
$email_db = mysql_real_escape_string($email);
$affiliation_db = mysql_real_escape_string($affiliation);
$food_db = mysql_real_escape_string($food);
$checkBoxDinner_db = $checkBoxDinner ? 1 : 0;
if ($emailVerify > 0) {
$emailAlreadyRegistered = 1;
} else {
$emailAlreadyRegistered = NULL;
}
// introdução dos valores na base de dados em caso de nao existencia de erro
if (!$firstnameEmpty && !$lastnameEmpty && !$emailEmpty && !$emailAlreadyRegistered && !$emailError && !$checkBoxPrivacyEmpty && !$affiliationEmpty) {
$sql = "INSERT INTO `$tablename` VALUES (NULL,
'$firstname_db',
'$lastname_db',
'$email_db',
'$affiliation_db',
'$food_db',
'$checkBoxDinner_db',
'0',
'0'
)";
$result = mysql_query($sql);
if (!$result) die(mysql_error() . "
" . $sql);
$flag_done = 1;
}
}
$textTop = "
Please fill the form below to register.
" ?>
if ((isset($_POST['submit']))){
if (isset($emailError)) $textTop.="
Please insert a valid email address!";
if (isset($emailAlreadyRegistered)) {
$textTop.="
This email is already registered.";
} elseif ($flag_done) {
if ($checkBoxDinner_db) {
$dinner_att = "You will attend the Meeting Social Dinner";
if ($food) $dinner_txt = "Dinner Preferences: " . $food;
else $dinner_txt = "";
} else {
$dinner_att = "You will not attend the Meeting Social Dinner";
$dinner_txt = "";
}
$mail = new smtp();
$mail_conn = $mail->openConnection();
if (!$mail_conn) die ("Connection to SMTP unavailable.");
$mail->setFrom($confEmail);
$mail->setFromName($confSignature . " LOC");
$mail->setSubject($confSignature . " registration acknowledgment");
$mail->setTo($email_db);
$mail->setCc($confEmail);
$mail->setMessage("
Dear ". $firstname . " ". $lastname .",
This is an automated message. Your registration has been sucessfully submitted.
Please, review your application details below. You can reply to this email if you have any doubt or need to change any information. \n
Thank you.
Personal Details
Name: " . $firstname . " " . $lastname . "
E-mail: " . $email . "
Affiliation: " . $affiliation . "
" . $dinner_att . "
" . $dinner_txt . "
Best regards,
" . $confSignature . " LOC");
$mail->send();
?>
Your application has been successfully submitted.
An automatic email has been sent with your application details, if you don't receive it, please, send an email to
helpdesk@iastro.pt.
Thank you.
Personal Information
Name: echo $firstname . " " . $lastname; ?>
E-mail: echo $email; ?>
Affiliation: echo $affiliation; ?>
echo $dinner_att; ?>
echo $dinner_txt; ?>
}
}
if (!$flag_done)
{
?>
echo $textTop ?>
}
?>