Change the color scheme to be more IHM rules compliant.
[Project_webapp.git] / includes / account.php
... / ...
CommitLineData
1<?php
2global $is_logged_in;
3if (!$is_logged_in) {
4 echo "Please login first. <br>";
5 $_SESSION['login_referer'] = $_SERVER['HTTP_REFERER'];
6 redirect("index.php?page=login", 2);
7 include('footer.html');
8 exit();
9}
10
11$action = filter_input(INPUT_GET, "action", FILTER_SANITIZE_STRING);
12
13global $connection;
14$sql_pquery = "select NomCl, PrenomCl, EmailCl, NumRueCl, NomRueCl, CodePosteCl, VilleCl from CLIENTS where EmailCl = ?";
15$connection->prepare_query($sql_pquery);
16$connection->prepared_query_bind_param("s", array($_SESSION['email']));
17$connection->run_prepared_query();
18$connection->get_pquery_result();
19$rows = $connection->get_result_array();
20$connection->close_prepared_query();
21
22if (empty($action)) {
23 echo "<h2>Mes informations</h2>\n";
24
25 echo "<table id=\"taccount\">\n";
26 foreach ($rows as $row) {
27 echo " <tr>\n";
28 echo " <td align=\"right\" valign=\"middle\">Pre&#769;nom : </td>\n";
29 echo " <td align=\"left\" valign=\"middle\">" . htmlentities($row['PrenomCl']) . "</td>\n";
30 echo " </tr>\n";
31
32 echo " <tr>\n";
33 echo " <td align=\"right\" valign=\"middle\">Nom : </td>\n";
34 echo " <td align=\"left\" valign=\"middle\">" . htmlentities($row['NomCl']) . "</td>\n";
35 echo " </tr>\n";
36
37 echo " <tr>\n";
38 echo " <td align=\"right\" valign=\"middle\">Email : </td>\n";
39 echo " <td align=\"left\" valign=\"middle\">" . htmlentities($row['EmailCl']) . "</td>\n";
40 echo " </tr>\n";
41
42 echo " <tr>\n";
43 echo " <td align=\"right\" valign=\"middle\">Adresse : </td>\n";
44 echo " <td align=\"left\" valign=\"middle\"></td>\n";
45 echo " </tr>\n";
46
47 echo " <tr>\n";
48 echo " <td align=\"right\" valign=\"middle\">Nume&#769;ro de rue : </td>\n";
49 echo " <td align=\"left\" valign=\"middle\">" . htmlentities($row['NumRueCl']) . "</td>\n";
50 echo " </tr>\n";
51
52 echo " <tr>\n";
53 echo " <td align=\"right\" valign=\"middle\">Rue : </td>\n";
54 echo " <td align=\"left\" valign=\"middle\">" . htmlentities($row['NomRueCl']) . "</td>\n";
55 echo " </tr>\n";
56
57 echo " <tr>\n";
58 echo " <td align=\"right\" valign=\"middle\">Code postal : </td>\n";
59 echo " <td align=\"left\" valign=\"middle\">" . htmlentities($row['CodePosteCl']) . "</td>\n";
60 echo " </tr>\n";
61
62 echo " <tr>\n";
63 echo " <td align=\"right\" valign=\"middle\">Ville : </td>\n";
64 echo " <td align=\"left\" valign=\"middle\">" . htmlentities($row['VilleCl']) . "</td>\n";
65 echo " </tr>\n";
66 }
67 echo "</table>\n";
68
69 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";
70 echo "<h2><a href=\"" . $configs['root_url'] . "/index.php?page=reservations\">Mes re&#769;servations</a></h2>\n";
71} elseif ($action === "modifyaccount") {
72 echo "
73 <form action=\"index.php\" id=\"faccount\" method=\"post\">
74 <input type=\"hidden\" name=\"form\" value=\"account\" />
75 <label> Pre&#769;nom : </label>
76 <input type=\"text\" size=\"25\" name=\"firstname\" value=\"" . $rows[0]['PrenomCl'] . "\" required/>
77 <label> Nom : </label>
78 <input type=\"text\" size=\"25\" name=\"name\" value=\"" . $rows[0]['NomCl'] . "\" required/>
79 <label> Email : </label>
80 <input type=\"email\" size=\"25\" name=\"email\" value=\"" . $rows[0]['EmailCl'] . "\" required/>
81 <label> Adresse : <br> Nume&#769;ro de rue : </label>
82 <input type=\"number\" size=\"5\" name=\"numstreet\" value=\"" . $rows[0]['NumRueCl'] . "\" required/>
83 <label> Rue : </label>
84 <input type=\"text\" size=\"50\" name=\"street\" value=\"" . $rows[0]['NomRueCl'] . "\" required/>
85 <label> Code postal : </label>
86 <input type=\"number\" size=\"5\" name=\"postalcode\" value=\"" . $rows[0]['CodePosteCl'] . "\" required/>
87 <label> Ville : </label>
88 <input type=\"text\" size=\"15\" name=\"city\" value=\"" . $rows[0]['VilleCl'] . "\" required/>
89 <input type=\"submit\" value=\"Valider\">
90 </form>
91 <br>\n";
92} elseif ($action === "modifypassword") {
93 echo "
94 <form action=\"index.php\" id=\"fpassword\" method=\"post\">
95 <input type=\"hidden\" name=\"form\" value=\"account\" />
96 <label> Ancien mot de passe : </label>
97 <input type=\"password\" size=\"15\" name=\"oldpassword\" required/>
98 <label> Nouveau mot de passe : </label>
99 <input type=\"password\" minlength=\"8\" size=\"15\" name=\"password\" pattern=\"(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*\" title=\"Doit contenir 8 caracte&#768;res minimum dont une majuscule, une minuscule et un chiffre\" required/>
100 <label> Confirmation du mot de passe : </label>
101 <input type=\"password\" minlength=\"8\" size=\"15\" name=\"confirmpassword\" pattern=\"(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*\" title=\"Doit contenir 8 caracte&#768;res minimum dont une majuscule, une minuscule et un chiffre\" required/>
102 <input type=\"submit\" value=\"Valider\">
103 </form>
104 <br>\n";
105} else {
106 echo "Unknown account action. <br>\n";
107}
108
109?>