par
anhdao » 09 sept. 2007, 16:38
Merci pour tes guides !
Enfin, les inscriptions des internautes arrivent au fichier participants.txt comme prévu mais pourquoi les barres de séparation des champs des données ||| ne se mettent qu'à la fin de la ligne mais ils ne séparent pas les données??
Et maintenant je veux aller un petit plus loin, comment faire pourque les inscriptions des internautes arrivent à une base de données MySQL, tu peux me guider??
Merci ZEUS et le forum
//pour n'avoir qu'un seul endroit où modifier le fichier
define('PARTICIPANTS_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['adressepostale1'] != ''
AND $_POST['adressepostale2'] != ''
AND $_POST['codepostal'] != ''
AND $_POST['ville'] != ''
AND $_POST['nbreadultes'] != ''
AND $_POST['nbreenfants'] != ''
AND $_POST['cinqans'] != ''
AND $_POST['dixans'] != ''
AND $_POST['quinzeans'] != ''
AND $_POST['plusdequinzeans'] != ''
AND $_POST['adulteprevu'] != ''
AND $_POST['enfantprevu'] != ''
AND $_POST['messages'] != '')
{//donnees ok
$nom = stripslashes($_POST['nom']);
$prenom = stripslashes($_POST['prenom']);
$tel = stripslashes($_POST['tel']);
$email = stripslashes($_POST['email']);
$adressepostale1 = stripslashes($_POST['adressepostale1']);
$adressepostale2 = stripslashes($_POST['adressepostale2']);
$ville = stripslashes($_POST['ville']);
$messages = stripslashes($_POST['messages']);
}
file_put_contents(PARTICIPANTS_FILE,$_POST,FILE_APPEND);
{
//écriture dans le fichier
$ligne = $nom. '|'.
$prenom. '|'.
$tel. '|'.
$email.'|'.
$adressepostale1. '|'.
$adressepostale2. '|'.
$codepostal. '|'.
$ville. '|'.
$nbreadultes. '|'.
$nbreenfants. '|'.
$cinqans. '|'.
$dixans. '|'.
$quinzeans. '|'.
$plusdequinzeans. '|'.
$adulteprevu. '|'.
$enfantprevu. '|'.
$messages." \r\n";
file_put_contents(PARTICIPANTS_FILE,$ligne,FILE_APPEND);
$message = 'inscription effectuée';
//pour empêcher le réaffichage des champs
unset($_POST);
}
}
{
$message = 'merci de remplir tous les champs';
}
}
?>
Code : Tout sélectionner
<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"
<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"> </td>
</tr>
<tr>
<td align="right" valign="top"><b>Prénom :</b></td>
<td valign="top"> <input name="prenom" type="text" size="50"> </td>
</tr>
<tr>
<td align="right" valign="top"><b>Téléphone :</b></td>
<td valign="top">
<input name="tel" type="text" size="10"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Adress Mail :</b></td>
<td valign="top"> <input name="email" type="text" size="50"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Adresse Postale 1:</b></td>
<td valign="top">
<input name="adressepostale1" type="text" value="" size="50"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Adresse Postale 2:</b></td>
<td valign="top">
<input name="adressepostale2" type="text" value="" size="50"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Code Postal :</b></td>
<td valign="top">
<input name="codepostal" type="text" value="" size="5"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Ville :</b></td>
<td valign="top">
<input name="ville" type="text" value="" size="50"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Nombre adultes :</b></td>
<td valign="top">
<input name="adultes" type="text" value="" size="2"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Nombre Enfants :</b></td>
<td valign="top">
<input name="enfants" type="text" value="" size="2"></td>
</tr>
<tr>
<td align="right" valign="top"><b>0 - 5 ans:</b></td>
<td valign="top">
<input name="cinqans" type="text" value="" size="2"></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"></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"></td>
</tr>
<tr>
<td align="right" valign="top"><b>plus de 15 ans :</b></td>
<td valign="top">
<input name="plusdequinzeans" type="text" value="" size="2"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Nous prévoyons d'être :</b></td>
<td valign="top">
<input name="adulteprevu" type="text" value="" size="2">
<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="enfantprevu" type="text" value="" size="2">
<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="message" 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>
</body>
</html>
Merci pour tes guides !
Enfin, les inscriptions des internautes arrivent au fichier participants.txt comme prévu mais pourquoi les barres de séparation des champs des données ||| ne se mettent qu'à la fin de la ligne mais ils ne séparent pas les données??
Et maintenant je veux aller un petit plus loin, comment faire pourque les inscriptions des internautes arrivent à une base de données MySQL, tu peux me guider??
Merci ZEUS et le forum
[php]
//pour n'avoir qu'un seul endroit où modifier le fichier
define('PARTICIPANTS_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['adressepostale1'] != ''
AND $_POST['adressepostale2'] != ''
AND $_POST['codepostal'] != ''
AND $_POST['ville'] != ''
AND $_POST['nbreadultes'] != ''
AND $_POST['nbreenfants'] != ''
AND $_POST['cinqans'] != ''
AND $_POST['dixans'] != ''
AND $_POST['quinzeans'] != ''
AND $_POST['plusdequinzeans'] != ''
AND $_POST['adulteprevu'] != ''
AND $_POST['enfantprevu'] != ''
AND $_POST['messages'] != '')
{//donnees ok
$nom = stripslashes($_POST['nom']);
$prenom = stripslashes($_POST['prenom']);
$tel = stripslashes($_POST['tel']);
$email = stripslashes($_POST['email']);
$adressepostale1 = stripslashes($_POST['adressepostale1']);
$adressepostale2 = stripslashes($_POST['adressepostale2']);
$ville = stripslashes($_POST['ville']);
$messages = stripslashes($_POST['messages']);
}
file_put_contents(PARTICIPANTS_FILE,$_POST,FILE_APPEND);
{
//écriture dans le fichier
$ligne = $nom. '|'.
$prenom. '|'.
$tel. '|'.
$email.'|'.
$adressepostale1. '|'.
$adressepostale2. '|'.
$codepostal. '|'.
$ville. '|'.
$nbreadultes. '|'.
$nbreenfants. '|'.
$cinqans. '|'.
$dixans. '|'.
$quinzeans. '|'.
$plusdequinzeans. '|'.
$adulteprevu. '|'.
$enfantprevu. '|'.
$messages." \r\n";
file_put_contents(PARTICIPANTS_FILE,$ligne,FILE_APPEND);
$message = 'inscription effectuée';
//pour empêcher le réaffichage des champs
unset($_POST);
}
}
{
$message = 'merci de remplir tous les champs';
}
}
?>
[/php]
[code]
<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"
<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"> </td>
</tr>
<tr>
<td align="right" valign="top"><b>Prénom :</b></td>
<td valign="top"> <input name="prenom" type="text" size="50"> </td>
</tr>
<tr>
<td align="right" valign="top"><b>Téléphone :</b></td>
<td valign="top">
<input name="tel" type="text" size="10"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Adress Mail :</b></td>
<td valign="top"> <input name="email" type="text" size="50"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Adresse Postale 1:</b></td>
<td valign="top">
<input name="adressepostale1" type="text" value="" size="50"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Adresse Postale 2:</b></td>
<td valign="top">
<input name="adressepostale2" type="text" value="" size="50"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Code Postal :</b></td>
<td valign="top">
<input name="codepostal" type="text" value="" size="5"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Ville :</b></td>
<td valign="top">
<input name="ville" type="text" value="" size="50"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Nombre adultes :</b></td>
<td valign="top">
<input name="adultes" type="text" value="" size="2"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Nombre Enfants :</b></td>
<td valign="top">
<input name="enfants" type="text" value="" size="2"></td>
</tr>
<tr>
<td align="right" valign="top"><b>0 - 5 ans:</b></td>
<td valign="top">
<input name="cinqans" type="text" value="" size="2"></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"></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"></td>
</tr>
<tr>
<td align="right" valign="top"><b>plus de 15 ans :</b></td>
<td valign="top">
<input name="plusdequinzeans" type="text" value="" size="2"></td>
</tr>
<tr>
<td align="right" valign="top"><b>Nous prévoyons d'être :</b></td>
<td valign="top">
<input name="adulteprevu" type="text" value="" size="2">
<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="enfantprevu" type="text" value="" size="2">
<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="message" 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>
</body>
</html>
[/code]