From b5f60f89589412e18b51326378ab13b9a4fa0f19 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 9 Jan 2018 22:14:39 +0100 Subject: [PATCH] Tidy a bit the files structure. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Workaround a bug in variable arguments number in the DB class. Signed-off-by: Jérôme Benoit --- footer.html | 5 ---- formlogin.php | 11 -------- account.php => includes/account.php | 0 booking.php => includes/booking.php | 0 config.php => includes/config.php | 0 includes/footer.html | 5 ++++ includes/formlogin.php | 16 +++++++++++ includes/formregister.php | 44 +++++++++++++++++++++++++++++ header.html => includes/header.html | 2 +- header.php => includes/header.php | 0 home.php => includes/home.php | 5 ++-- includes/login.php | 6 ++++ includes/register.php | 15 ++++++++++ search.php => includes/search.php | 0 index.php | 44 +++++++++++++++++------------ lib/db.php | 11 ++++---- login.php | 6 ---- register.php | 0 18 files changed, 121 insertions(+), 49 deletions(-) delete mode 100644 footer.html delete mode 100644 formlogin.php rename account.php => includes/account.php (100%) rename booking.php => includes/booking.php (100%) rename config.php => includes/config.php (100%) create mode 100644 includes/footer.html create mode 100644 includes/formlogin.php create mode 100644 includes/formregister.php rename header.html => includes/header.html (76%) rename header.php => includes/header.php (100%) rename home.php => includes/home.php (78%) create mode 100644 includes/login.php create mode 100644 includes/register.php rename search.php => includes/search.php (100%) delete mode 100644 login.php delete mode 100644 register.php diff --git a/footer.html b/footer.html deleted file mode 100644 index e06db19..0000000 --- a/footer.html +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/formlogin.php b/formlogin.php deleted file mode 100644 index f3b8765..0000000 --- a/formlogin.php +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/account.php b/includes/account.php similarity index 100% rename from account.php rename to includes/account.php diff --git a/booking.php b/includes/booking.php similarity index 100% rename from booking.php rename to includes/booking.php diff --git a/config.php b/includes/config.php similarity index 100% rename from config.php rename to includes/config.php diff --git a/includes/footer.html b/includes/footer.html new file mode 100644 index 0000000..733dbb9 --- /dev/null +++ b/includes/footer.html @@ -0,0 +1,5 @@ + + + diff --git a/includes/formlogin.php b/includes/formlogin.php new file mode 100644 index 0000000..8da2e2c --- /dev/null +++ b/includes/formlogin.php @@ -0,0 +1,16 @@ +"; +} else { + $sql_pquery = "select count(NumCI) from CLIENTS where EmailCI = ?"; + + echo "This email do not belong to a registred client, please register first
"; + + if (password_verify($form_password, $stored_password)) { + + } +} +?> diff --git a/includes/formregister.php b/includes/formregister.php new file mode 100644 index 0000000..53b5f6d --- /dev/null +++ b/includes/formregister.php @@ -0,0 +1,44 @@ +" ; + $error_numstreet = true; +} +if (!$form_postalcode) { + echo "The postal code is not valid
"; + $error_postalcode = true; +} +if (!$form_email) { + echo "The email is not valid
"; + $error_email = true; +} +if (strcmp($form_password, $form_confirmpassword) === 0) { + echo "Password do not match
"; + $error_password = true; +} + +if (!empty($form_name) && !empty($form_firstname) && !empty($form_numstreet) && !empty($form_street) && + !empty($form_postalcode) && !empty($form_town) && !empty($form_email) && !empty($form_password)){ + global $connection; + $sql_pquery = "select count(NumCl) from CLIENTS where EmailCl = ?"; + $stmt = $connection->prepare_query($sql_pquery); + $stmt->bind_param("s", $form_email); + //$connection->prepared_query_bind_param("s", $form_email); + $connection->run_prepared_query(); + $connection->close_prepared_query(); +} +?> diff --git a/header.html b/includes/header.html similarity index 76% rename from header.html rename to includes/header.html index 5721c7d..602e0cf 100644 --- a/header.html +++ b/includes/header.html @@ -4,7 +4,7 @@ Air Polytech - + diff --git a/header.php b/includes/header.php similarity index 100% rename from header.php rename to includes/header.php diff --git a/home.php b/includes/home.php similarity index 78% rename from home.php rename to includes/home.php index 5499ba9..cc378a2 100644 --- a/home.php +++ b/includes/home.php @@ -1,9 +1,9 @@ query($requete); echo "\n"; @@ -17,7 +17,6 @@ function home() } echo "
\n"; $result->close(); - $connection->close(); } home(); diff --git a/includes/login.php b/includes/login.php new file mode 100644 index 0000000..19c74da --- /dev/null +++ b/includes/login.php @@ -0,0 +1,6 @@ +
+ +

Email :

+

Mot de passe :

+

+
diff --git a/includes/register.php b/includes/register.php new file mode 100644 index 0000000..72b9884 --- /dev/null +++ b/includes/register.php @@ -0,0 +1,15 @@ +
+ +

Nom :

+

Prénom :

+

Adresse :

+

Numéro de rue : + Rue : + Code postal : + Ville : +

+

Email :

+

Mot de passe :

+

Confirnation du mot de passe :

+

+
diff --git a/search.php b/includes/search.php similarity index 100% rename from search.php rename to includes/search.php diff --git a/index.php b/index.php index 9d22f3e..8bceb64 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ "; } $found_action = true; break; } } if (!$found_action) { - echo "Action to display do not exist"; + echo "Action to display do not exist
"; } } -$url_action = get_url_action(); +//password_hash('12345678', PASSWORD_DEFAULT); + +$action_type = get_action_type(); +$url_action = get_url_action($action_type); $action = validate_url_action($url_action); -display_action($action); +display_action($action, $action_type); + +$connection->close(); session_destroy(); -require('footer.html'); +require('includes/footer.html'); ?> diff --git a/lib/db.php b/lib/db.php index 0f280a4..b548804 100644 --- a/lib/db.php +++ b/lib/db.php @@ -52,7 +52,7 @@ class CustomDB public function query($sql_query) { if ($this->connected && !($query_result = $this->connection->query($sql_query))) { - echo "Fail to execute the SQL query : " . $sql_query; + echo "Fail to execute the SQL query : " . $sql_query . "
"; } return $query_result; } @@ -68,7 +68,7 @@ class CustomDB if ($this->connected && !($this->current_stmt = $this->connection->prepare($this->current_pquery))) { // Empty the currently stored prepared query in the failure case $this->current_pquery = ""; - echo "Fail to prepare SQL query : (" . $this->connection->errno . ") " . $this->connection->error . " - " . $this->current_pquery; + echo "Fail to prepare SQL query : (" . $this->connection->errno . ") " . $this->connection->error . " - " . $this->current_pquery . "
"; } return $this->current_stmt; } @@ -80,9 +80,10 @@ class CustomDB */ public function prepared_query_bind_param(...$params) { + var_dump($params); $rt_val = $this->current_stmt->bind_param($params); if (!$rt_val) { - echo "Fail to link parameters to SQL query : (" . $this->current_stmt->errno . ") " . $this->current_stmt->error . " - " . $this->current_pquery; + echo "Fail to link parameters to SQL query : (" . $this->current_stmt->errno . ") " . $this->current_stmt->error . " - " . $this->current_pquery . "
"; } return $rt_val; } @@ -95,7 +96,7 @@ class CustomDB { $rt_val = $this->current_stmt->execute(); if (!$rt_val) { - echo "Fail to execute SQL query : (" . $this->current_stmt->errno . ") " . $this->current_stmt->error . " - " . $this->current_pquery; + echo "Fail to execute SQL query : (" . $this->current_stmt->errno . ") " . $this->current_stmt->error . " - " . $this->current_pquery . "
"; } return $rt_val; } @@ -108,7 +109,7 @@ class CustomDB { $rt_val = $this->current_stmt->close(); if (!$rt_val) { - echo "Fail to close SQL query : (" . $this->current_stmt->errno . ") " . $this->current_stmt->error . " - " . $this->current_pquery; + echo "Fail to close SQL query : (" . $this->current_stmt->errno . ") " . $this->current_stmt->error . " - " . $this->current_pquery . "
"; } return $rt_val; } diff --git a/login.php b/login.php deleted file mode 100644 index e976fc9..0000000 --- a/login.php +++ /dev/null @@ -1,6 +0,0 @@ -
- -

Email :

-

Mot de passe :

-

-
diff --git a/register.php b/register.php deleted file mode 100644 index e69de29..0000000 -- 2.34.1