Workaround a bug in variable arguments number in the DB class.
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
+++ /dev/null
-<div id="footer">
- ©2018 - <a href="https://piment-noir.org">Piment Noir</a>
-</div>
-</body>
-</html>
+++ /dev/null
-<?php
-$form_email = filter_input(INPUT_POST, "email", FILTER_VALIDATE_EMAIL);
-$form_password = filter_input(INPUT_POST, "password", FILTER_SANITIZE_STRING);
-
-if (!$form_email) {
- echo "The email is not valid";
-} else {
- $sql_pquery = "select count() from Client where EmailCI = ?";
-}
-
-?>
--- /dev/null
+<div id="footer">
+ ©2018 - Made by <a href="https://piment-noir.org">Piment Noir</a>
+</div>
+</body>
+</html>
--- /dev/null
+<?php
+$form_email = filter_input(INPUT_POST, "email", FILTER_VALIDATE_EMAIL);
+$form_password = filter_input(INPUT_POST, "password", FILTER_SANITIZE_STRING);
+
+if (!$form_email) {
+ echo "The email is not valid <br>";
+} else {
+ $sql_pquery = "select count(NumCI) from CLIENTS where EmailCI = ?";
+
+ echo "This email do not belong to a registred client, please register first <br>";
+
+ if (password_verify($form_password, $stored_password)) {
+
+ }
+}
+?>
--- /dev/null
+<?php
+$form_name = filter_input(INPUT_POST, "name", FILTER_SANITIZE_STRING);
+$form_firstname = filter_input(INPUT_POST, "firstname", FILTER_SANITIZE_STRING);
+$form_numstreet = filter_input(INPUT_POST, "numstreet", FILTER_VALIDATE_INT);
+$form_street = filter_input(INPUT_POST, "street", FILTER_SANITIZE_STRING);
+$form_postalcode = filter_input(INPUT_POST, "postalcode", FILTER_VALIDATE_INT);
+$form_town = filter_input(INPUT_POST, "postalcode", FILTER_SANITIZE_STRING);
+$form_email = filter_input(INPUT_POST, "email", FILTER_VALIDATE_EMAIL);
+$form_password = filter_input(INPUT_POST, "password", FILTER_SANITIZE_STRING);
+$form_confirmpassword = filter_input(INPUT_POST, "confirmpassword", FILTER_SANITIZE_STRING);
+
+$error_numstreet = false;
+$error_postalcode = false;
+$error_email = false;
+$error_password = false;
+
+if (!$form_numstreet) {
+ echo "The street number is not valid <br>" ;
+ $error_numstreet = true;
+}
+if (!$form_postalcode) {
+ echo "The postal code is not valid <br>";
+ $error_postalcode = true;
+}
+if (!$form_email) {
+ echo "The email is not valid <br>";
+ $error_email = true;
+}
+if (strcmp($form_password, $form_confirmpassword) === 0) {
+ echo "Password do not match <br>";
+ $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();
+}
+?>
<head>
<title>Air Polytech</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<link href="https://fonts.googleapis.com/css?family=Encode+Sans+Semi+Condensed" rel="stylesheet">
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Encode+Sans+Semi+Condensed">
<link rel="stylesheet" type="text/css" href="styles/airpolytech.css" />
</head>
<body>
<?php
+
function home()
{
- global $configs;
+ global $connection;
- $connection = new CustomDB($configs['host'], $configs['username'], $configs['password'], $configs['database']);
$requete = "SELECT NumCl, NomCl, CodePosteCl, VilleCl FROM CLIENTS";
$result = $connection->query($requete);
echo "<table border=1>\n";
}
echo "</table>\n";
$result->close();
- $connection->close();
}
home();
--- /dev/null
+<form action="index.php" method="post">
+ <input type="hidden" name="form" value="login" />
+ <p> Email : <input type="text" name="email" /> </p>
+ <p> Mot de passe : <input type="password" name="password" /> </p>
+ <p> <input type="submit" value="Valider"> </p>
+</form>
--- /dev/null
+<form action="index.php" method="post">
+ <input type="hidden" name="form" value="register" />
+ <p> Nom : <input type="text" name="name" /> </p>
+ <p> Prénom : <input type="text" name="firstname" /> </p>
+ <p> Adresse : </p>
+ <p> Numéro de rue : <input type="text" name="numstreet" />
+ Rue : <input type="text" name="street" />
+ Code postal : <input type="text" name="postalcode" />
+ Ville : <input type="text" name="town" />
+ </p>
+ <p> Email : <input type="text" name="email" /> </p>
+ <p> Mot de passe : <input type="password" name="password" /> </p>
+ <p> Confirnation du mot de passe : <input type="password" name="confirmpassword" /> </p>
+ <p> <input type="submit" value="Valider"> </p>
+</form>
<?php
-require('header.php');
+require('includes/header.php');
include('lib/db.php');
include('lib/utils.php');
*/
session_start();
+$connection = new CustomDB($configs['host'], $configs['username'], $configs['password'], $configs['database']);
+
$page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_URL);
$isPage = true;
if (!isset($page)) {
}
}
-function get_url_action() {
+function get_url_action($action_type) {
global $page, $form;
- if (get_action_type() === "page") {
+ if ($action_type === "page") {
return $page;
- } elseif (get_action_type() === "form") {
+ } elseif ($action_type === "form") {
return $form;
- } elseif (get_action_type() === "empty") {
+ } elseif ($action_type === "empty") {
return "";
- } elseif (get_action_type() === "unknown") {
- die('Cannot get a valid action from URL parameters');
+ } elseif ($action_type === "unknown") {
+ die('Cannot get a valid action from URL parameters or form fields');
}
}
return $configs['actions'][0];
}
-function display_action($action_name)
+function display_action($action_name, $action_type)
{
- global $configs, $isPage, $isForm;
+ global $configs;
+ $includes_rpath = 'includes';
$found_action = false;
foreach ($configs['actions'] as $action) {
if (strcmp($action_name, $action) === 0) {
// HTTP GET case
- if (get_action_type() === "page" || get_action_type() === "empty") {
- include($action . ".php");
+ if ($action_type === "page" || $action_type === "empty") {
+ include($includes_rpath . "/" . $action . ".php");
// HTTP POST case
- } elseif (get_action_type() === "form") {
- include("form" . $action . ".php");
+ } elseif ($action_type === "form") {
+ include($includes_rpath . "/form" . $action . ".php");
} else {
- echo "Unknown error in action displaying";
+ echo "Unknown error in action displaying <br>";
}
$found_action = true;
break;
}
}
if (!$found_action) {
- echo "Action to display do not exist";
+ echo "Action to display do not exist <br>";
}
}
-$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');
?>
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 . "<br>";
}
return $query_result;
}
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 . "<br>";
}
return $this->current_stmt;
}
*/
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 . "<br>";
}
return $rt_val;
}
{
$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 . "<br>";
}
return $rt_val;
}
{
$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 . "<br>";
}
return $rt_val;
}
+++ /dev/null
-<form action="index.php" method="post">
- <input type="hidden" name="form" value="login" />
- <p>Email : <input type="text" name="email" /></p>
- <p>Mot de passe : <input type="text" name="password" /></p>
- <p><input type="submit" value="OK"></p>
-</form>