parent
3f78318f08
commit
a5a22a55ad
@ -1,8 +0,0 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<form action="action.php" method="post">
|
||||
<input type="text" name="name" placeholder="name" /><br>
|
||||
<input type="text" name="password" placeholder="password" /></p>
|
||||
<p><input type="submit" value="OK"></p>
|
||||
</form>
|
||||
</html>
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
class Validation {
|
||||
|
||||
static function val_action($action)
|
||||
{
|
||||
if (!isset($action))
|
||||
{
|
||||
throw new Exception('pas d\'action');
|
||||
}
|
||||
}
|
||||
|
||||
static function val_form(string &$name, string &$password, array &$dVueEreur)
|
||||
{
|
||||
|
||||
if (!isset($name)||$name=="") {
|
||||
$dVueEreur[] = "pas de nom";
|
||||
$name="";
|
||||
}
|
||||
|
||||
if ($name != filter_var($name, FILTER_SANITIZE_STRING))
|
||||
{
|
||||
$dVueEreur[] = "testative d'injection de code (attaque sécurité)";
|
||||
$nom="";
|
||||
}
|
||||
|
||||
if (!isset($password)||$password=="") {
|
||||
$dVueEreur[] = "pas de mot de passe ";
|
||||
$password="";
|
||||
}
|
||||
|
||||
if ($password != filter_var($password, FILTER_SANITIZE_STRING))
|
||||
{
|
||||
$dVueEreur[] = "testative d'injection de code (attaque sécurité)";
|
||||
$password="";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
$validation = new Validation();
|
||||
$error =[];
|
||||
$validation->val_form($_POST['name'],$_POST['password'],$error);
|
||||
Foreach ($error as $key) {
|
||||
print($key);
|
||||
}
|
||||
?>
|
@ -0,0 +1,8 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<form action="Validation.php" method="POST">
|
||||
<input type="text" name="name" placeholder="name" /><br>
|
||||
<input type="text" name="password" placeholder="password" />
|
||||
<input type="submit" value="OK">
|
||||
</form>
|
||||
</html>
|
Loading…
Reference in new issue