Au secours et merci
<?php
//pour n'avoir qu'un seul endroit où modifier le fichier
define('PARTICIPANT_FILE', 'participants.txt');
if (!empty($_POST))
{//formulaire soumis
/* *******************
inscription
********************* */
if(isset($_POST['inscri']))
{
if ($_POST['nom'] !=''
AND $_POST['prenom'] !=''
AND $_POST['tel'] !=''
AND $_POST['email'] !=''
AND $_POST['adressepostale'] !=''
AND $_POST['codepostal'] !=''
AND $_POST['ville'] !=''
AND $_POST['nbreadulte'] !=''
AND $_POST['nbreenfant'] !=''
AND $_POST['cinqans'] !=''
AND $_POST['dixans'] !=''
AND $_POST['quinzeans'] !=''
AND $_POST['plusdequinzeans'] !=''
AND $_POST['nbreadulteprevu'] !=''
AND $_POST['nbreenfantprevu'] !=''
AND $_POST['messages'] !='')
{//donnees ok
$nom = stripslashes($_POST['nom']);
$prenom = stripslashes($_POST['prenom']);
$tel = stripslashes($_POST['tel']);
$email = stripslashes($_POST['email']);
$adressepostale = stripslashes($_POST['adressepostale']);
$codepostal = stripslashes($_POST['codepostal']);
$Ville = stripslashes($_POST['ville']);
$nbreadulte = stripslashes($_POST['nbreadulte']);
$nbreenfant = stripslashes($_POST['nbreenfant']);
$cinqans = stripslashes($_POST['cinqans']);
$dixans = stripslashes($_POST['dixans']);
$quinzeans = stripslashes($_POST['quinzeans']);
$plusdequinzeans = stripslashes($_POST['plusdequinzeans']);
$nbreadulteprevu = stripslashes($_POST['nbreadulteprevu']);
$nbreenfantprevu = stripslashes($_POST['nbreenfantprevu']);
$messages = stripslashes($_POST['messages']);
}
else
{
//écriture dans le fichier
$ligne = $nom.'|'.
$prenom.'|'.
$tel.'|'.
$email.'|'.
$adressepostale.'|'.
$codepostal.'|'.
$ville.'|'.
$nbreadulte.'|'.
$nbreenfant.'|'.
$cinqans.'|'.
$dixans.'|'.
$quinzeans.'|'.
$plusdequinzeans.'|'.
$nbreadulteprevu .'|'.
$nbreenfantprevu.'|'.
$messages."\r\n";
file_put_contents(PARTICIPANT_FILE,$ligne,FILE_APPEND);
$message = 'inscription effectuée';
//pour empêcher le réaffichage des champs
unset($_POST);
}
}
else
{
$message = 'merci de remplir tous les champs';
}
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<p> </p>
<form method="post" action="participants.php" "<?php echo $_SERVER['PHP_SELF']; ?>">
<table width="90%" border="0" cellspacing="2" cellpadding="4">
<tr>
<td width="33%" height="30" colspan="3" valign="top" bgcolor="#003399"><div align="center"><font color="#CCCCCC"><b>Formulaire d'inscription participant </b></font></div></td>
</tr>
<tr>
<td colspan="2" align="right" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="27%" align="right" valign="top"><b>Nom :</b></td>
<td width="79%" valign="top"> <input name="nom" type="text" size="50" value="<?php echo $_POST['nom']; ?>" > </td>
</tr>
<tr>
<td align="right" valign="top"><b>Prénom :</b></td>
<td valign="top"> <input name="prenom" type="text" size="50" value="<?php echo $_POST['prenom']; ?>" > </td>
</tr>
<tr>
<td align="right" valign="top"><b>Téléphone :</b></td>
<td valign="top">
<input name="tel" type="text" size="10" value="<?php echo $_POST['tel']; ?>" >
</td>
</tr>
<tr>
<td align="right" valign="top"><b>Adresse Mail :</b></td>
<td valign="top"> <input name="email" type="text" size="50" value="<?php echo $_POST['email']; ?>" > </td>
</tr>
<tr>
<td align="right" valign="top"><b>Adresse postale :</b></td>
<td valign="top">
<input name="adressepostale" type="text" value="" size="50" value="<?php echo $_POST['adressepostale']; ?>">
</td>
</tr>
<tr>
<td align="right" valign="top"> </td>
<td valign="top">
<input name="adressepostale" type="text" value="" size="50" value="<?php echo $_POST['adressepostale']; ?>">
</td>
</tr>
<tr>
<td align="right" valign="top"><b>Code postal :</b></td>
<td valign="top">
<input name="codepostal" type="text" value="" size="5" value="<?php echo $_POST['codepostal']; ?>">
</td>
</tr>
<tr>
<td align="right" valign="top"><b>Ville :</b></td>
<td valign="top">
<input name="ville" type="text" value="" size="50" value="<?php echo $_POST['ville']; ?>">
</td>
</tr>
<tr>
<td align="right" valign="top"><b>Nombre d'adultes :</b></td>
<td valign="top">
<input name="nbreadulte" type="text" value="" size="2" value="<?php echo $_POST['nbreadulte']; ?>" >
</td>
</tr>
<tr>
<td align="right" valign="top"><b>Nombre d'enfants :</b></td>
<td valign="top">
<input name="nbreenfant" type="text" value="" size="2" value="<?php echo $_POST['nbreenfant']; ?>" >
</td>
</tr>
<tr>
<td align="right" valign="top"><b> 0 - 5 <font color="#FFFFFF">a</font>ans :</b></td>
<td valign="top">
<input name="cinqans" type="text" value="" size="2" value="<?php echo $_POST['cinqans']; ?>" >
</td>
</tr>
<tr>
<td align="right" valign="top"><b>5 - 10 ans :</b></td>
<td valign="top">
<input name="dixans" type="text" value="" size="2" value="<?php echo $_POST['dixans']; ?>" >
</td>
</tr>
<tr>
<td align="right" valign="top"><b>10 - 15 ans :</b></td>
<td valign="top">
<input name="quinzeans" type="text" value="" size="2" value="<?php echo $_POST['quinzeans']; ?>" >
</td>
</tr>
<tr>
<td align="right" valign="top"><b>+ de 15 ans :</b></td>
<td valign="top">
<input name="plusdequinzeans" type="text" value="" size="2" value="<?php echo $_POST['plusdequinzeans']; ?>" >
</td>
</tr>
<tr>
<td align="right" valign="top"><b>Nous prévoyons d'être :</b></td>
<td valign="top">
<input name="nbreadulteprevu" type="text" value="" size="2" value="<?php echo $_POST['nbreadulteprevu']; ?>">
<b>adultes</b> <strong>le 30 Septembre </strong></td>
</tr>
<tr>
<td align="right" valign="top"><b>Nous prévoyons d'être :</b></td>
<td valign="top">
<input name="nbreenfantprevu" type="text" value="" size="2" value="<?php echo $_POST['nbreenfantprevu']; ?>" >
<b>enfants </b><strong>le 30 Septembre </strong></td>
</tr>
<tr>
<td align="right" valign="top"><b>Message :</b></td>
<td valign="top"> <textarea name="messages" rows="10" cols="50" wrap="VIRTUAL"> </textarea> </td>
</tr>
<tr>
<td align="right" valign="top"><p> </p></td>
<td> <input type="submit" name="inscri" value="Envoyer"> <input type="reset" name="inscri" value="Annuler"></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="3" valign="top">
<hr width="90%" size="1" noshade></td></tr>
</table>
</form>
<?php echo $message; ?>
</body>
</html>