Add return flight booking cinematic and personal informations editing.
[Project_webapp.git] / includes / account.php
index 073d5adfc0f73ae1aced29bb7ff7837590149130..7b2c366b4ddca7069f086142609a3a07189a994c 100644 (file)
@@ -2,11 +2,98 @@
 global $is_logged_in;
 if (!$is_logged_in) {
     echo "Please login first. <br>";
+    $_SESSION['login_referer'] = $_SERVER['HTTP_REFERER'];
     redirect("index.php?page=login", 2);
     include('footer.html');
     exit();
 }
-?>
 
-<h2>Mes informations</h2>
-<h2><a href="<?php echo $configs['root_url']; ?>/index.php?page=reservations">Mes re&#769;servations</a></h2>
+$action = filter_input(INPUT_GET, "action", FILTER_SANITIZE_STRING);
+
+global $connection;
+$sql_pquery = "select NomCl, PrenomCl, EmailCl, NumRueCl, NomRueCl, CodePosteCl, VilleCl from CLIENTS where EmailCl = ?";
+$connection->prepare_query($sql_pquery);
+$connection->prepared_query_bind_param("s", array($_SESSION['email']));
+$connection->run_prepared_query();
+$connection->get_pquery_result();
+$rows = $connection->get_result_array();
+$connection->close_prepared_query();
+
+if (empty($action)) {
+    echo "<h2>Mes informations</h2>\n";
+
+    echo "<table id=\"account\">\n";
+    foreach ($rows as $row) {
+        echo " <tr>\n";
+        echo "  <td>Nom : </td>\n";
+        echo "  <td>" . htmlentities($row['NomCl']) . "</td>\n";
+        echo " </tr>\n";
+
+        echo " <tr>\n";
+        echo "  <td>Pre&#769;nom : </td>\n";
+        echo "  <td>" . htmlentities($row['PrenomCl']) . "</td>\n";
+        echo " </tr>\n";
+
+        echo " <tr>\n";
+        echo "  <td>Email : </td>\n";
+        echo "  <td>" . htmlentities($row['EmailCl']) . "</td>\n";
+        echo " </tr>\n";
+
+        echo " <tr>\n";
+        echo "  <td>Adresse : </td>\n";
+        echo "  <td></td>\n";
+        echo " </tr>\n";
+
+        echo " <tr>\n";
+        echo "  <td>Nume&#769;ro de rue : </td>\n";
+        echo "  <td>" . htmlentities($row['NumRueCl']) . "</td>\n";
+        echo " </tr>\n";
+
+        echo " <tr>\n";
+        echo "  <td>Rue : </td>\n";
+        echo "  <td>" . htmlentities($row['NomRueCl']) . "</td>\n";
+        echo " </tr>\n";
+
+        echo " <tr>\n";
+        echo "  <td>Code postal : </td>\n";
+        echo "  <td>" . htmlentities($row['CodePosteCl']) . "</td>\n";
+        echo " </tr>\n";
+
+        echo " <tr>\n";
+        echo "  <td>Ville : </td>\n";
+        echo "  <td>" . htmlentities($row['VilleCl']) . "</td>\n";
+        echo " </tr>\n";
+    }
+    echo "</table>\n";
+
+    echo "| <a href=\"" . $configs['root_url'] . "/index.php?page=account&action=modifyaccount\">Modifier vos informations</a> | <a href=\"" . $configs['root_url'] . "/index.php?page=account&action=modifypassword\">Modifier votre mot de passe</a> |\n";
+    echo "<h2><a href=\"" . $configs['root_url'] . "/index.php?page=reservations\">Mes re&#769;servations</a></h2>\n";
+} elseif ($action === "modifyaccount") {
+    echo "
+    <form action=\"index.php\" id=\"account\" method=\"post\">
+     <input type=\"hidden\" name=\"form\" value=\"account\" />
+     <label> Nom : </label>
+     <input type=\"text\" size=\"25\" name=\"name\" value=\"" . $rows[0]['NomCl'] . "\" required/>
+     <label> Pre&#769;nom : </label>
+     <input type=\"text\" size=\"25\" name=\"firstname\" value=\"" . $rows[0]['PrenomCl'] . "\" required/>
+         <label> Adresse : <br> Nume&#769;ro de rue : </label>
+         <input type=\"number\" size=\"5\" name=\"numstreet\" value=\"" . $rows[0]['NumRueCl'] . "\" required/>
+         <label> Rue : </label>
+         <input type=\"text\" size=\"50\" name=\"street\" value=\"" . $rows[0]['NomRueCl'] . "\" required/>
+         <label> Code postal : </label>
+         <input type=\"number\" size=\"5\" name=\"postalcode\" value=\"" . $rows[0]['CodePosteCl'] . "\" required/>
+         <label> Ville : </label>
+         <input type=\"text\" size=\"15\" name=\"city\" value=\"" . $rows[0]['VilleCl'] . "\" required/>
+     <label> Email : </label>
+     <input type=\"email\" size=\"25\" name=\"email\" value=\"" . $rows[0]['EmailCl'] . "\" required/>
+     <input type=\"submit\" value=\"Valider\">
+    </form>
+    <br>\n";
+} elseif ($action === "modifypassword") {
+    echo "Work in progress. <br>\n";
+    redirect("index.php?page=account", 3);
+} else {
+    echo "Unknown account action. <br>\n";
+}
+
+?>