<!DOCTYPE html>
<html>
<head>
<title>E-permanence</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control " content="no-cache">
<style>
label {
display:block;
margin: 20px 0 5px 0;
}
</style>
</head>
<body>
<h1>Inscription</h1>
<form name="form" method="post" action="$$valeurs.php">
<label for="nom">Nom*</label>
<input name="nom" type="text" id="nom" maxlength="20">
<label for="prenom">Prenom*</label>
<input name="prenom" type="text" id="prenom" maxlength="20">
<label for="mail">Mail*</label>
<input name="mail" type="email" id="mail" maxlength="20">
<label for="sexe">Votre sexe</label>
<input name="sexe" type="text" id="sexe">
<label for="profession">Votre profession</label>
<input name="profession" type="text" id="profession">
<p><input type="submit" value="go"></p>
</form>
</body>
</html>
<?php
// si qqch est posté ($_POST = tableau)
if(isset($_POST)) {
// pour chaque valeur du tableau
foreach ($_POST as $key => $post) {
// transforme la clé (form name) en variable et attribue lui sa valeur correspondante
${$key} = strip_tags(trim($post));
}
}
/* $nom = '';
$prenom = '';
$mail = '';
$sexe = '';
$profession = '';
*/
$tab = array('nom', 'prenom', 'mail', 'sexe', 'profession');
foreach($tab as $value) {
if (!isset(${$value})) {
${$value} = '';
// die(var_dump($value));
}
}
if(empty($nom) || empty($prenom) || empty($mail)) { ?>
<html>
<head>
<title>Avertissement</title>
</head>
<body>
<?php // header("Location:e-perm_homepprofession.php?inscription=no&prob=1"); ?>
<h1>Erreur</h1>
<p style="font-weight:bold; color:#990000;">Veuillez remplir tous les champs requis</p>
<p><a href="e-perm_register.php">Retour</a></p>
</body>
</html>
<?php
} else {
var_dump($nom);
var_dump($prenom);
var_dump($mail);
var_dump($sexe);
var_dump($profession);
}
?>
- Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.14, 8.4.1
- <!DOCTYPE html>
<html>
<head>
<title>E-permanence</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control " content="no-cache">
<style>
label {
display:block;
margin: 20px 0 5px 0;
}
</style>
</head>
<body>
<h1>Inscription</h1>
<form name="form" method="post" action="$$valeurs.php">
<label for="nom">Nom*</label>
<input name="nom" type="text" id="nom" maxlength="20">
<label for="prenom">Prenom*</label>
<input name="prenom" type="text" id="prenom" maxlength="20">
<label for="mail">Mail*</label>
<input name="mail" type="email" id="mail" maxlength="20">
<label for="sexe">Votre sexe</label>
<input name="sexe" type="text" id="sexe">
<label for="profession">Votre profession</label>
<input name="profession" type="text" id="profession">
<p><input type="submit" value="go"></p>
</form>
</body>
</html>
<html>
<head>
<title>Avertissement</title>
</head>
<body>
<h1>Erreur</h1>
<p style="font-weight:bold; color:#990000;">Veuillez remplir tous les champs requis</p>
<p><a href="e-perm_register.php">Retour</a></p>
</body>
</html>
preferences:
79.48 ms | 412 KiB | 5 Q