XXVII National Meeting of Astronomy and Astrophysics (ENAA)20-21 July 2017, Lisboa, Portugal
require_once($_SERVER['DOCUMENT_ROOT'] . "/../includes/smtp.php");
$tablename1=$confAcronym . "_reg";
$tablename=$confAcronym . "_abs";
// Criar o objecto
$email = isset($_POST['email']) ? $_POST['email'] : NULL;
$type = isset($_POST['type']) ? $_POST['type'] : NULL;
$title = isset($_POST['title']) ? $_POST['title'] : NULL;
$abstract = isset($_POST['abstract']) ? $_POST['abstract'] : NULL;
$email = trim($email);
$type = trim($type);
$title = trim($title);
$abstract = trim($abstract);
$flag_done = isset($_POST['flag_done']) ? $_POST['flag_done'] : NULL;
$double = NULL;
if (isset($_POST['submit']) && $_POST['submit']) {
// Verificação dos resultados
$emailEmpty = !$email ? 1 : NULL;
$abstractEmpty = !$abstract ? 1 : NULL;
$titleEmpty = !$title ? 1 : NULL;
$typeEmpty = !$type ? 1 : NULL;
if($type==1){
$type_details="Poster";
}elseif($type==2){
$type_details="Oral contribution";
}
$email=strtolower($email);
$query = "SELECT * FROM `$tablename1` WHERE email = '$email'";
$emailVerify = mysql_num_rows(mysql_query($query));
$result=mysql_query($query);
$detalhes=mysql_fetch_assoc($result);
$name=$detalhes['firstname'].' '.$detalhes['lastname'];
$emailError= !ereg("[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]", $email) ? 1: NULL;
$email_db = mysql_real_escape_string($email);
$title_db = mysql_real_escape_string($titlet);
$abstract_db = mysql_real_escape_string($abstract);
$type_db = mysql_real_escape_string($type);
if ($emailVerify > 0) {
$emailAlreadyRegistered = NULL;
} else {
$emailAlreadyRegistered = 1;
}
// introdução dos valores na base de dados em caso de nao existencia de erro
if (!$emailEmpty && !$emailAlreadyRegistered && !$emailError && !$abstractEmpty && !$typeEmpty && !$titleEmpty) {
$sql = "INSERT INTO `$tablename` VALUES (NULL,
'$email_db',
'$type_db',
'$title_db',
'$abstract_db',
'0',
'0'
)";
$result = mysql_query($sql);
if (!$result) die(mysql_error() . "
" . $sql);
$flag_done = 1;
}
}
if ((isset($_POST['submit']))){
if (isset($emailError)) $textTop.="
Please insert a valid email address!";
if (isset($emailAlreadyRegistered)) {
$textTop.="
This email is not yet registered.";
} elseif ($flag_done) {
$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 ". $name .",
This is an automated message. Your application 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.
Submission Details
E-mail: " . $email . "
Type: " . $type_details . "
Title: " . $title . "
Abstract: " . $abstract . "
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 xxviienaa@iastro.pt.
Thank you.
Name: > echo $mail; ?>
E-mail: echo $email; ?>
Type: echo $type_details; ?>
Title: echo $title; ?>
Abstract: echo $abstract; ?>
}
}
if (!$flag_done)
{
?>
echo $textTop ?>
}
?>