Commit | Line | Data |
---|---|---|
a96fefe1 JB |
1 | <?php |
2 | global $is_logged_in; | |
3 | if (!$is_logged_in) { | |
a2f7a729 | 4 | echo "Please login first. <br>"; |
22f1dc64 | 5 | $_SESSION['login_referer'] = $_SERVER['HTTP_REFERER']; |
a96fefe1 | 6 | redirect("index.php?page=login", 2); |
01135b89 | 7 | include('footer.html'); |
f78b3417 | 8 | exit(); |
a96fefe1 | 9 | } |
33eb6f2a | 10 | |
22f1dc64 JB |
11 | $action = filter_input(INPUT_GET, "action", FILTER_SANITIZE_STRING); |
12 | ||
13 | global $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 | ||
22 | if (empty($action)) { | |
23 | echo "<h2>Mes informations</h2>\n"; | |
24 | ||
25 | echo "<table id=\"account\">\n"; | |
26 | foreach ($rows as $row) { | |
27 | echo " <tr>\n"; | |
28 | echo " <td>Nom : </td>\n"; | |
29 | echo " <td>" . htmlentities($row['NomCl']) . "</td>\n"; | |
30 | echo " </tr>\n"; | |
31 | ||
32 | echo " <tr>\n"; | |
33 | echo " <td>Prénom : </td>\n"; | |
34 | echo " <td>" . htmlentities($row['PrenomCl']) . "</td>\n"; | |
35 | echo " </tr>\n"; | |
36 | ||
37 | echo " <tr>\n"; | |
38 | echo " <td>Email : </td>\n"; | |
39 | echo " <td>" . htmlentities($row['EmailCl']) . "</td>\n"; | |
40 | echo " </tr>\n"; | |
41 | ||
42 | echo " <tr>\n"; | |
43 | echo " <td>Adresse : </td>\n"; | |
44 | echo " <td></td>\n"; | |
45 | echo " </tr>\n"; | |
46 | ||
47 | echo " <tr>\n"; | |
48 | echo " <td>Numéro de rue : </td>\n"; | |
49 | echo " <td>" . htmlentities($row['NumRueCl']) . "</td>\n"; | |
50 | echo " </tr>\n"; | |
51 | ||
52 | echo " <tr>\n"; | |
53 | echo " <td>Rue : </td>\n"; | |
54 | echo " <td>" . htmlentities($row['NomRueCl']) . "</td>\n"; | |
55 | echo " </tr>\n"; | |
56 | ||
57 | echo " <tr>\n"; | |
58 | echo " <td>Code postal : </td>\n"; | |
59 | echo " <td>" . htmlentities($row['CodePosteCl']) . "</td>\n"; | |
60 | echo " </tr>\n"; | |
61 | ||
62 | echo " <tr>\n"; | |
63 | echo " <td>Ville : </td>\n"; | |
64 | echo " <td>" . 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 réservations</a></h2>\n"; | |
71 | } elseif ($action === "modifyaccount") { | |
72 | echo " | |
73 | <form action=\"index.php\" id=\"account\" method=\"post\"> | |
74 | <input type=\"hidden\" name=\"form\" value=\"account\" /> | |
75 | <label> Nom : </label> | |
76 | <input type=\"text\" size=\"25\" name=\"name\" value=\"" . $rows[0]['NomCl'] . "\" required/> | |
77 | <label> Prénom : </label> | |
78 | <input type=\"text\" size=\"25\" name=\"firstname\" value=\"" . $rows[0]['PrenomCl'] . "\" required/> | |
79 | <label> Adresse : <br> Numéro de rue : </label> | |
80 | <input type=\"number\" size=\"5\" name=\"numstreet\" value=\"" . $rows[0]['NumRueCl'] . "\" required/> | |
81 | <label> Rue : </label> | |
82 | <input type=\"text\" size=\"50\" name=\"street\" value=\"" . $rows[0]['NomRueCl'] . "\" required/> | |
83 | <label> Code postal : </label> | |
84 | <input type=\"number\" size=\"5\" name=\"postalcode\" value=\"" . $rows[0]['CodePosteCl'] . "\" required/> | |
85 | <label> Ville : </label> | |
86 | <input type=\"text\" size=\"15\" name=\"city\" value=\"" . $rows[0]['VilleCl'] . "\" required/> | |
87 | <label> Email : </label> | |
88 | <input type=\"email\" size=\"25\" name=\"email\" value=\"" . $rows[0]['EmailCl'] . "\" required/> | |
89 | <input type=\"submit\" value=\"Valider\"> | |
90 | </form> | |
91 | <br>\n"; | |
92 | } elseif ($action === "modifypassword") { | |
93 | echo "Work in progress. <br>\n"; | |
94 | redirect("index.php?page=account", 3); | |
95 | } else { | |
96 | echo "Unknown account action. <br>\n"; | |
97 | } | |
98 | ||
99 | ?> |