<?php

$hostname = 'mysql.db.uclouvain.be:3350';

$username = 'fronts2025';

$password = '3Qgnb(4WMCu34N_(';

try {
    $dbh = new PDO("mysql:host=$hostname;dbname=fronts2025", $username, $password);
    }
catch(PDOException $e)
    {
    echo $e->getMessage();
    }    
    
    
    
/*$result = $dbh->query("SELECT * FROM inscriptions"); 
while ($data = $result->fetch())
{

//nom prénom institution

//chambre 1 ou 2

//partenaire

//participation

}*/
    
    
?>

<!DOCTYPE html>
<html lang="fr">
    <title>FRONTS 2025</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta name="keywords" content="mesh generation, workshop, finite elements">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
  
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Onglets Intercalaires</title>
    <style>
        body {
            font-family: helvetica,sans-serif;
    background-color: #ffffff;
            max-width: 1200px;
            margin: auto;
            padding: 15px;
        }

        .content {
    padding: 0 0px;
    display: none;
    overflow: hidden;
    
} 
.collapsible {
    background-color: #f4f4f4;
    color: black;
    cursor: pointer;
    padding: 14px;
    width: 100%;
    border: solid grey 1px;
    text-align: left;
    outline: 1px;
    font-size: 18px;
    position: relative; /* Nécessaire pour positionner la flèche */
}

.collapsible::after {
    content: '\25BC'; /* Code Unicode pour une flèche droite */
    position: absolute;
    right: 14px; /* Alignement avec le padding */
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: black;
    transition: transform 0.3s ease; /* Animation pour la rotation */
}

.collapsible.active::after {
    transform: translateY(-50%) rotate(180deg); /* Flèche vers le bas */
}
        
  /* Style du tableau en mode desktop */
        .responsive-table {
            display: table;
            width: 100%;
            border-collapse: collapse;
        }

        .responsive-row {
            display: flex;
            flex: 1;
            
        }

        .responsive-cell {
            flex: 1;
            padding: 10px;
            border: 1px solid #ccc;
            text-align: left;
            display: flex;
            align-items: center;
        }

        .responsive-header {
            text-align: center;
            background-color: #fafafa;
            font-weight: bold;
        }

        /* Adaptation pour les petits écrans */
        @media (max-width: 768px) {
            .responsive-table {
                display: block;
            }

            .responsive-row {
                display: flex;
                flex-direction: column;
            }

            .responsive-cell {
                display: block;
                width: 100%;
            }

            /* Les titres des colonnes s'affichent en tant que labels pour chaque cellule */
            .responsive-header {
                display: none; /* Masque les en-têtes en mode mobile */
            }

            .responsive-cell::before {
                content: attr(data-title); /* Utilise l'attribut personnalisé 'data-title' */
                font-weight: bold;
                display: block;
                margin-bottom: 5px;
                color: #333;
            }
        }
        
    </style>
</head>
<body>
    
    <h2>Fronts 2025 registration form.</h2>
    
<?php    
    
$rempli=$_POST['rempli'];
    
if ($rempli=='1')    
{    
$name = htmlspecialchars($_POST['name'], ENT_QUOTES);
$first = htmlspecialchars($_POST['first'], ENT_QUOTES);
$mail = $_POST['mail'];
$instit = htmlspecialchars($_POST['instit'], ENT_QUOTES);
    
    if ($name!='' AND $first!='' AND $mail!='' AND $instit!='')
    {
    
    $title = htmlspecialchars($_POST['title'], ENT_QUOTES);
    $abstract = htmlspecialchars($_POST['abstract'], ENT_QUOTES);
    $room = htmlspecialchars($_POST['room'], ENT_QUOTES);
        $gender = htmlspecialchars($_POST['gender'], ENT_QUOTES);
    $arrival = htmlspecialchars($_POST['arrival'], ENT_QUOTES);
    $sat = htmlspecialchars($_POST['sat'], ENT_QUOTES);
    $sun = htmlspecialchars($_POST['sun'], ENT_QUOTES);
    $mon = htmlspecialchars($_POST['mon'], ENT_QUOTES);
    $tue = htmlspecialchars($_POST['tue'], ENT_QUOTES);
    $wed = htmlspecialchars($_POST['wed'], ENT_QUOTES);
    $thu = htmlspecialchars($_POST['thu'], ENT_QUOTES);
    $excursion = htmlspecialchars($_POST['excursion'], ENT_QUOTES);
    $allergies = htmlspecialchars($_POST['allergies'], ENT_QUOTES);
    $diet = htmlspecialchars($_POST['diet'], ENT_QUOTES);
        
        $billing = htmlspecialchars($_POST['billing'], ENT_QUOTES);
        $vat = htmlspecialchars($_POST['vat'], ENT_QUOTES);
    
   /* $pass = htmlspecialchars($_POST['pass'], ENT_QUOTES);
    $status = htmlspecialchars($_POST['status'], ENT_QUOTES); */
    
    $result = $dbh->query("SELECT * FROM registration WHERE mail='$mail'");   
    $data = $result->fetch();
    
    if ($data['mail']!='')
    {
        echo "<p>Sorry, it seems the email address is already used. For any help or information, please contact us at <a href='mailto:fronts-2025@uclouvain.be'>fronts-2025@uclouvain.be<a>.</p>";
    }
    else
    {
$dbh->exec("INSERT INTO registration (name, first, mail, instit) VALUES ('$name', '$first', '$mail', '$instit')");
    
    if ($title!='') $dbh->exec("UPDATE registration SET title='$title' WHERE mail='$mail'");
    if ($abstract!='') $dbh->exec("UPDATE registration SET abstract='$abstract' WHERE mail='$mail'");
    if ($room!='') $dbh->exec("UPDATE registration SET room='$room' WHERE mail='$mail'");
        if ($gender!='') $dbh->exec("UPDATE registration SET gender='$gender' WHERE mail='$mail'");
    if ($arrival!='') $dbh->exec("UPDATE registration SET arrival='$arrival' WHERE mail='$mail'");
    if ($sat!='') $dbh->exec("UPDATE registration SET sat='$sat' WHERE mail='$mail'");
    if ($sun!='') $dbh->exec("UPDATE registration SET sun='$sun' WHERE mail='$mail'");
    if ($mon!='') $dbh->exec("UPDATE registration SET mon='$mon' WHERE mail='$mail'");
    if ($tue!='') $dbh->exec("UPDATE registration SET tue='$tue' WHERE mail='$mail'");
    if ($wed!='') $dbh->exec("UPDATE registration SET wed='$wed' WHERE mail='$mail'");
    if ($thu!='') $dbh->exec("UPDATE registration SET thu='$thu' WHERE mail='$mail'");
    if ($excursion!='') $dbh->exec("UPDATE registration SET excursion='$excursion' WHERE mail='$mail'");
    if ($allergies!='') $dbh->exec("UPDATE registration SET allergies='$allergies' WHERE mail='$mail'");
    if ($diet!='') $dbh->exec("UPDATE registration SET diet='$diet' WHERE mail='$mail'");
        if ($billing!='') $dbh->exec("UPDATE registration SET billing='$billing' WHERE mail='$mail'");
        if ($vat!='') $dbh->exec("UPDATE registration SET vat='$vat' WHERE mail='$mail'");
        
     include ("mail.php");
        
        echo "<p>Thank you, your registration has been recorded, you should receive the confirmation email any moment.<br />For any help or information, please contact us at <a href='mailto:fronts-2025@uclouvain.be'>fronts-2025@uclouvain.be<a>.</p>";
        
    }
    }
    else echo "<p>Sorry, one of the compulsory fields has not been filled. Please <a href='https://sites.uclouvain.be/fronts2025/registration.php'>try again</a>.</p>";
}
    
else
{    
?>    

<form action='' method='post'>
    
    <p>(*) = compulsory field</p>
    
<fieldset>
    <legend>Personnal info</legend>    
<p>
Name(*): <input type='text' name='name'><br />   
First name(*): <input type='text' name='first'><br />
Email(*): <input type='email' name='mail'><br />
Institution(*): <input type='text' name='instit'><br /><br />
    Billing address: <input type='text' name='billing'><br />
    VAT number: <input type='text' name='vat'>
<!--- <br />Choose your password (it will be useful if you wish to submit an abstract later):<br />
<input type='password' name='pass'> --->
</p>
    </fieldset>
    
   <fieldset>
    <legend>Conference talks</legend> 
    <p>Invited speakers will give a 40' talk, other speakers will give a 20' talk.</p>
       <p><b>If you wish to give a talk,</b> please provide a<br />
       Title: <input type='text' name='title'><br />
       and a max. 200 words abstract:<br />
      <textarea name='abstract'></textarea> 
       
       </p>
       
    </fieldset>
    
 <fieldset>
    <legend>Accomodation</legend>
     <p>
     <input type='radio' name='room' value='single'> Single room: 820€ per person.<br />
     <input type='radio' name='room' value='shared'> Shared room (2 people): 670€ per person.   Gender: <input type='radio' name='gender' value='M'> M <input type='radio' name='gender' value='F'> F<br />
     <input type='radio' name='room' value='none'> Conference only (lodgment non included): 520€ per person
     </p>
     <p>Arrival date:<br />
     <input type='radio' name='arrival' value='13'> Saturday, September 13th <br/>
     <input type='radio' name='arrival' value='14'> Sunday, September 14th <br/>
     <input type='radio' name='arrival' value='15'> Monday, September 15th <br/>
     <input type='radio' name='arrival' value='16'> Tuesday, September 16th <br/>
     <input type='radio' name='arrival' value='17'> Wednesday, September 17th 
     
     </p>
    </fieldset>     
<fieldset>
    <legend>On-site details</legend>
    <p>In order to host you confortably, we need to know some details. <br />Please check the boxes if you wish to participate to the activities.</p>
    
     <P>
    Food allergies: <input type='text' name='allergies'><br />
    Special diet: <input type='text' name='diet'>
    </P>
    
    <p>
        <input type='checkbox' name='sat' value='1'><b>Saturday, September 13th:</b><br />
- Check in (after 16:00).<br />
 - Welcome Dinner buffet with red/white wine.
        
        <br /><br />
 
        <input type='checkbox' name='sun' value='1'><b>Sunday, September 14th:</b><br />
- Breakfast.<br />
- Up to two coffee breaks.<br />
- Lunch buffet with red/white wine.<br />
- Dinner buffet with red/white wine.<br />
        <br />
 
        <input type='checkbox' name='mon' value='1'><b>Monday, September 15th:</b><br />
- Breakfast.<br />
- Up to two coffee breaks.<br />
- Lunch buffet with red/white wine.<br />
- Dinner buffet with red/white wine.<br />
        
        <br />
        <input type='checkbox' name='excursion' value='1'><b>Excursion by bus to the beach of Falassarna.</b> <a href='https://discoverkissamos.com/place/falassarna-beach/'>https://discoverkissamos.com/place/falassarna-beach/</a>
        <br /><br />
 
        <input type='checkbox' name='tue' value='1'><b>Tuesday, September 16th:</b><br />
- Breakfast.<br />
- Up to two coffee breaks.<br />
- Lunch buffet with red/white wine.<br />
- Cretan Night dinner buffet with red/white wine and raki including live music show and dancers.<br /> 
        
        <br />
 
        <input type='checkbox' name='wed' value='1'><b>Wednesday, September 17th:</b><br />
- Breakfast.<br />
- Up to two coffee breaks.<br />
- Lunch buffet with red/white wine.<br />
        
        <br />
 
        <input type='checkbox' name='thu' value='1'><b>Thursday, September 18th:</b><br />
- Breakfast.<br />
- Check out 9:30am<br />
    
    </p>
   
    
    </fieldset>
    <input type='hidden' name='rempli' value='1'>
    <p><input type='submit' value='submit'></p>

</form>
    
<?php
}
?>    

    </body></html>