K2 meeting10-11 May 2016, Porto, Portugal
require_once($_SERVER['DOCUMENT_ROOT'] . "/../includes/phpmailer/class.phpmailer.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/../includes/phpmailer/class.smtp.php");
$date = date("Ymd");
$tablename=$confAcronym . "_reg";
// Criar o objecto
if (isset($_GET['email'])) {
$email = mysql_real_escape_string($_GET['email']);
} else $email = isset($_POST['email']) ? $_POST['email'] : NULL;
$firstname = sql_ifget_value('k2meeting_reg', 'firstname', 'email = "' . $email . '"');
$lastname = sql_ifget_value('k2meeting_reg', 'lastname', 'email = "' . $email . '"');
$institute = sql_ifget_value('k2meeting_reg', 'institute', 'email = "' . $email . '"');
$country = sql_ifget_value('k2meeting_reg', 'country', 'email = "' . $email . '"');
$dinner = isset($_POST['dinner']) ? $_POST['dinner'] : NULL;
$foodRestrictions = isset($_POST['foodRestrictions']) ? $_POST['foodRestrictions'] : NULL;
$instituteInvoice = isset($_POST['instituteInvoice']) ? $_POST['instituteInvoice'] : NULL;
$vatInvoice = isset($_POST['vatInvoice']) ? $_POST['vatInvoice'] : NULL;
$addressInvoice = isset($_POST['addressInvoice']) ? $_POST['addressInvoice'] : NULL;
$zipCodeInvoice = isset($_POST['zipCodeInvoice']) ? $_POST['zipCodeInvoice'] : NULL;
$cityInvoice = isset($_POST['cityInvoice']) ? $_POST['cityInvoice'] : NULL;
$countryInvoice = isset($_POST['countryInvoice']) ? $_POST['countryInvoice'] : NULL;
$flag_done = isset($_POST['flag_done']) ? $_POST['flag_done'] : NULL;
$double = NULL;
if (isset($_POST['submit']) && $_POST['submit']) {
// Verificação dos resultados
$dinnerEmpty = !$dinner ? 1 : NULL;
$instituteInvoiceEmpty = (!$instituteInvoice && $dinner == 2) ? 1 : NULL;
$vatInvoiceEmpty = (!$vatInvoice && $dinner == 2) ? 1 : NULL;
$addressInvoiceEmpty = (!$addressInvoice && $dinner == 2) ? 1 : NULL;
$zipCodeInvoiceEmpty = (!$zipCodeInvoice && $dinner == 2) ? 1 : NULL;
$cityInvoiceEmpty = (!$cityInvoice && $dinner == 2) ? 1 : NULL;
$countryInvoiceEmpty = (!$countryInvoice && $dinner == 2) ? 1 : NULL;
$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;
// remover caracteres estranhos
$foodRestrictions_db = htmlentities(mysql_real_escape_string($foodRestrictions), ENT_QUOTES);
$instituteInvoice_db = htmlentities(mysql_real_escape_string($instituteInvoice), ENT_QUOTES);
$vatInvoice_db = htmlentities(mysql_real_escape_string($vatInvoice), ENT_QUOTES);
$addressInvoice_db = htmlentities(mysql_real_escape_string($addressInvoice), ENT_QUOTES);
$zipCodeInvoice_db = htmlentities(mysql_real_escape_string($zipCodeInvoice), ENT_QUOTES);
$cityInvoice_db = htmlentities(mysql_real_escape_string($cityInvoice), ENT_QUOTES);
// introdução dos valores na base de dados em caso de nao existencia de erro
if (!$dinnerEmpty && !$instituteInvoiceEmpty && !$vatInvoiceEmpty && !$addressInvoiceEmpty && !$zipCodeInvoiceEmpty && !$cityInvoiceEmpty && !$countryInvoiceEmpty)
{
$sql = "UPDATE `$tablename` SET dinner = '$dinner',
foodRestrictions = '$foodRestrictions_db',
instituteInvoice = '$instituteInvoice_db',
vatInvoice = '$vatInvoice_db',
addressInvoice = '$addressInvoice_db',
zipCodeInvoice = '$zipCodeInvoice_db',
cityInvoice = '$cityInvoice_db',
countryInvoice = '$countryInvoice'
WHERE email='$email'";
$result = mysql_query($sql);
if (!$result) die(mysql_error() . "
" . $sql);
$flag_done=1;
} else $textError = "
There was a problem with your submission, please verify the marked fields.
";
}
if (!empty($email)) $textTop="
Dear $firstname $lastname, please fill the form below to update your details.
";
else $textTop="
Please fill the form below to update your details.
Important: insert below the same email used for your registration.
" ?>
if ((isset($_POST['submit']))){
if (isset($textError)) $textTop.= $textError;
if ($flag_done) {
$country_mail = sql_ifget_value('country', 'printable_name', 'iso = "' . $country . '"');
if ($dinner == '2') {
$paymentInfo = "
Payment information
";
if ($limitReached == TRUE) {
$paymentInfo .= "The payment information will be sent as soon as your registration is validated.
";
} else {
$paymentInfo .= "The registration must be paid by bank transfer.
We require all international transfers to us to be made with OUR instruction. OUR instruction means you pay all transfer charges.
Please clearly identify your name when doing your transfer, and notify the LOC by e-mail (
Elsa.Silva@astro.up.pt). In your e-mail, if possible please mention the reference code of the transfer (or any clear identifier), or send us a file with the bank's receipt.
Your registration will only be confirmed once we receive full payment of the registration fee.
Account Holder: Centro de Investigação em Astronomia/Astrofísica da Universidade do Porto
Bank Name: Caixa Geral de Depósitos
Bank Adress: Praca Mouzinho de Albuquerque no 113, Edifício Brasília, PT-4100-359 Porto, Portugal
IBAN CODE : PT50 0035 0160 00061936230 05
SWIFT/BIC CODE: CGDIPTPL
";
}
} else {
$paymentInfo = "";
}
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SetFrom("helpdesk@iastro.pt", "Instituto de Astrofísica e Ciências do Espaço");
$mail->AddAddress($email, $firstname . " " . $lastname);
$mail->AddCc("helpdesk@iastro.pt", "Instituto de Astrofisica e Ciências do Espaço");
$mail->AddBcc("Alexandre.Santerne@astro.up.pt", "Alexandre Santerne");
$mail->Subject = "K2 meeting data update acknowledgment";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML("
Dear ". $firstname . " ". $lastname .",
This is an automated message. Your registration has been successfully updated.
Thank you.
Name: ".$lastname.", ".$firstname."
E-mail: ".$email."
Institution: ".$institute. "
Country: " . $country_mail . "
" . $paymentInfo . "
Best regards,
K2 meeting LOC");
//$mail->AddAttachment("images/phpmailer.gif"); // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
$mail->Send();
?>
Your registration has been successfully updated. Thank you.
Information
Name: echo $lastname .", ".$firstname; ?>
E-mail: echo $email; ?>
Affiliation: echo $institute; ?>
echo $paymentInfo; ?>
}
}
if (!$flag_done)
{
?>
echo $textTop ?>
}
?>