treatement.
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
--- /dev/null
+<?php
+$form_email = filter_input(INPUT_POST, "email", FILTER_VALIDATE_EMAIL);
+$form_password = filter_input(INPUT_POST, "password", FILTER_VALIDATE_STRING);
+
+if (!form_email) {
+ echo "The email " .$form_email . " is not valid";
+} else {
+ $sql_pquery = "select count() from Client where EmailCI = ?";
+}
+
+?>
<?php
require('header.php');
<?php
require('header.php');
/**
* Let's use an array as the list of tunables.
* Put in a variable the inclusion of this file:
/**
* Let's use an array as the list of tunables.
* Put in a variable the inclusion of this file:
-//$page = filter_input(INPUT_GET, $_GET['page'], FILTER_SANITIZE_URL);
-$page = $_GET['page'];
-
+$page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_URL);
+$isPage = true;
+$form = filter_input(INPUT_POST, 'form', FILTER_SANITIZE_URL);
+$isForm = true;
+if (!isset($form)) {
+ $isForm = false;
+ $form = "";
+}
+
- * [valid_page validate if the current page is a valid site actions]
+ * [validate_url_action validate if the current page is a valid site actions]
* @param [string] $page [the viewed page name]
* @return [string] [the valid matching action or the default action
* if the action name do not exist ]
*/
* @param [string] $page [the viewed page name]
* @return [string] [the valid matching action or the default action
* if the action name do not exist ]
*/
-function valid_page($page_name)
+function validate_url_action($action_name)
{
global $configs;
foreach ($configs['actions'] as $action) {
{
global $configs;
foreach ($configs['actions'] as $action) {
- if (strcmp($page_name, $action) === 0) {
+ if (strcmp($action_name, $action) === 0) {
// The actions list can't have duplicated entries
return $action;
}
// The actions list can't have duplicated entries
return $action;
}
return $configs['actions'][0];
}
return $configs['actions'][0];
}
+function get_action_type() {
+ global $page, $form, $isPage, $isForm;
+
+ if ($isPage && !$isForm) {
+ return "page";
+ } elseif ($isForm && !$isPage) {
+ return "form";
+ } elseif (!$isPage && !$isForm){
+ return "empty";
+ } else {
+ return "unknown";
+ }
+}
+
function display_action($action_name)
{
function display_action($action_name)
{
+ global $configs, $isPage, $isForm;
$found_action = false;
foreach ($configs['actions'] as $action) {
if (strcmp($action_name, $action) === 0) {
$found_action = false;
foreach ($configs['actions'] as $action) {
if (strcmp($action_name, $action) === 0) {
- include("$action.php");
+ if (get_action_type() === "page" || get_action_type() === "empty") {
+ include($action . ".php");
+ } elseif (get_action_type() === "form") {
+ include("form" . $action . ".php");
+ } else {
+ echo "Impossible error";
+ }
$found_action = true;
break;
}
$found_action = true;
break;
}
-$action = valid_page($page);
+function get_url_action() {
+ global $page, $form, $isPage, $isForm;
+
+ if (get_action_type() === "page") {
+ return $page;
+ } elseif (get_action_type() === "form") {
+ return $form;
+ } elseif (get_action_type() === "empty") {
+ return "";
+ } elseif (get_action_type() === "unknown") {
+ die('Cannot get a valid action from URL parameters');
+ }
+}
+
+$url_action = get_url_action();
+$action = validate_url_action($url_action);
display_action($action);
session_destroy();
display_action($action);
session_destroy();
--- /dev/null
+<?php
+function isPostRequest() {
+ if (filter_input(INPUT_SERVER, 'REQUEST_METHOD') === 'POST') {
+ return true;
+ } else {
+ return false;
+ }
+}
+?>
-<form action="action.php" method="post">
+<form action="index.php?form=login" method="post">
<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>
<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>