1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| <?php
session_start();
function mail_secure($value,$token1,$token2)
{
if (isset($value) && $value != "" && isset($token1) && $token2 == $token1)
{
$verif = eregi('^[[:alnum:]\.\_\-]+@[[:alnum:]\.\-]+\.[[:alpha:]]{2,4}$', $value);
if ($verif == "1")
{
$string = $value;
return $string;
}
}
}
/* chiffre, texte multilingue, espace, tabulation, ponctuation acceptés */
function text_secure($value,$token1,$token2)
{
if (isset($value) && $value != "" && isset($token1) && $token2 == $token1)
{
$verif = eregi('^[[:alnum:][:blank:][:punct:]\&\;]{1,}$', htmlentities($value));
if ($verif == "1")
{
$string = mb_convert_encoding(htmlentities(trim(strip_tags($value))),"HTML-ENTITIES","UTF-8");
return $string;
}
}
}
/* chiffre, texte multilingue, espace, tabulation, ponctuation, code html acceptés */
function text_secure($value,$token1,$token2)
{
if (isset($value) && $value != "" && isset($token1) && $token2 == $token1)
{
$verif = eregi('^[[:alnum:][:blank:][:punct:]\&\;]{1,}$', htmlentities($value));
if ($verif == "1")
{
$string = mb_convert_encoding(htmlentities(trim($value)),"HTML-ENTITIES","UTF-8");
return $string;
}
}
}
if (!empty($_POST['register']))
{
$test1 = mail_secure($_POST['email'],$_SESSION['token'],$_POST['token']);
echo $test1,"<br />";
$test2 = text_secure($_POST['words'],$_SESSION['token'],$_POST['token']);
echo $test2,"<br />";
}
$token = md5(uniqid(rand(), true));
$_SESSION['token'] = $token;
?>
<form method="post" action="security.php">
<input type="text" name="email">
<br>
<input type="text" name="words">
<br>
<input type="hidden" name="token" value="<?php echo $token; ?>">
<input type="submit" name="register" value="Soumettre">
</form> |
Partager