[html/php]recuperation de données de plusieur formulaire

Petit nouveau ! | 2 Messages

03 févr. 2014, 12:40

Bonjour,
je suis actuellement en train de réaliser une application concernant le remplacement de fenêtre de toit et j'ai un soucis car j'ai créer plusieurs formulaires pour que l'utilisateur personnalise le nom de sa fenêtre comme par exemple la fenêtre 1 on peut la renommer la fenêtre 2 aussi car je souhaite faire afficher le nom de la fenêtre puis le champs texte pour renommer avec le nom de la fenêtre en placeholder.
Quand je clique sur le bouton renommer de la fenêtre 1 cela remplace bien le nom par contre quand je clique sur celui de la fenêtre 2 le nom de la fenêtre est vide.
Je ne vois pas comment faire pour que quand on clique sur ce deuxième bouton le nom de la première fenêtre ne change pas.


Voici mon code HTML
<h1 style="text-align-center">Remplacement VELUX®, Configurez-les vous-mêmes ! en 1 clin d'oeil.</h1>

<div style="background-color:rgb(128,204,40);">
	<form name="Formfenetre" id="FormFenetre"action="http://localhost/alphacombles/test-formulaire-2" method="post" style="background-color:rgb(128,204,40);">
		<table style="font-size:13px; border-collapse:collapse;">
			<tbody>
                         <tr>
			   <td style="text-align:center;margin:0px auto;">
			    taille<span style="color:red;">*</span>:
                            <img  src="http://localhost/alphacombles/wp-content/uploads/2014/01/cote.jpg" style="height:80px;width:70px;margin-left:2px;" />
			  </td>
					<td style="text-align:center;margin:0px auto;">
						vitrage<span style="color:red;">*</span>:
                                                 <img  src="http://localhost/alphacombles/wp-content/uploads/2014/01/velux-standard.jpg" style="height:100px;width:100px;margin-left:2px;" />
                                         </td>
					<td style="text-align:center;margin:0px auto;">
						finition<span style="color:red;">*</span>:
                                                <img src="http://localhost/alphacombles/wp-content/uploads/2014/01/finition-bois-verni-VELUX.jpg" style="height:50px;width:50px;margin-left:2px;" />
                                                <img src="http://localhost/alphacombles/wp-content/uploads/2014/01/finition-coque-blanche-VELUX.jpg" style="height:50px;width:50px;margin-left:2px;" />
					</td>
					<td style="text-align:center;margin:0px auto;">
						ouverture<span style="color:red;">*</span>:
                                                <img src="http://localhost/alphacombles/wp-content/uploads/2014/01/ouverture-par-projection1.jpg" style="height:100px;width:100px;margin-left:2px;" />
					</td>
					<td style="text-align:center;">
						tuile<span style="color:red;">*</span>:
					</td>
					<td style="text-align:center;margin:0px auto;">
						stores:
					</td>
					<td style="text-align:center;margin:0px auto;">
						volet:
					</td>
				</tr>
			</tbody>
		</table>
		<table style="background-color:rgb(128,204,40)">
			<tbody>
				[php function=3]
				<tr>
					<td>
						<select id="tailleFenetre1" name="tailleFenetre1" style="width:57px;font-size:8.4px;margin-left:1px;"><option>Taille</option><option value="55x70">55x70</option><option value="55x78">55X78</option><option value="55x98">55X98</option><option value="78x98">78X98</option><option value="78x118">78X118</option><option value="78x140">78X140</option><option value="114x118">114X118</option><option value="114x140">114X140</option><option value="134x98">134X98</option><option value="134x140">134X140</option> </select>
					</td>
					<td>
						<select id="vitrageFenetre1" name="vitrageFenetre1" style="font-size:9px;"><option>vitrage</option><option value="Standard">Standard</option><option value="Confort">Confort</option><option value="Tout confort">Tout confort</option> </select>
					</td>
					<td>
						<select id="finitionFenetre1" name="finitionFenetre1" style="font-size:9.4px;width:150px;"><option>finition</option><option value="Bois vernis TopFinish">Bois vernis TopFinish</option><option>Coque blanche sans entretien</option> </select>
					</td>
					<td>
						<select name="ouvertureFenetre1" style="font-size:9.4px;"><option>type ouverture</option><option>rotation</option><option>projection</option><option>motoris&eacute;</option> </select>
					</td>
					<td>
						<select name="tuileFenetre1" style="font-size:9.4px;width:100px;"><option>tuile</option><option>Petites tuiles plates</option><option>Tuiles m&eacute;caniques</option><option>Ardoise</option> </select>
					</td>
					<td>
						<select name="storeFenetre1" style="font-size:9.40px;"><option>stores</option><option>Occultants</option><option>Tamisants</option><option>Pare-soleil</option><option>Moustiquaire</option> </select>
					</td>
					<td>
						<select name="voletFenetre1" style="font-size:9.4px;"><option>volet</option><option>SSL</option><option>SML</option> </select>
					</td>
				</tr>
			</tbody>
		</table>
               <input id="BoutSubFormFenetre1" name="BoutSubFormFenetre1" style="font-size:9.4px;margin-left:595px;color:white;height:23px;" type="submit" value="rechercher" />
		</form>
		<form name="Formfenetre2" id="FormFenetre2"action="http://localhost/alphacombles/test-formulaire-2" method="post" style="background-color:rgb(128,204,40);">
		
			<table style="background-color:rgb(128,204,40)">
			<tbody>
				fenetre 2:<input style="width:200px;margin-left:5px;height:9.5px;font-size:9.4px" maxlength="100" type="text" name="fenetre2Nom"id="fenetre2Nom" placeholder="chambre de Charlotte"> <input style="width:100px;margin-left:5px;height:20px;font-size:9.4px;" type="submit" name="fenetre2Boutton"id="fenetre2Boutton"value="rennommer">

				<tr>
					<td>
						<select id="tailleFenetre2" name="tailleFenetre2" style="width:57px;font-size:8.4px;margin-left:1px;"><option>Taille</option><option value="55x70">55x70</option><option value="55x78">55X78</option><option value="55x98">55X98</option><option value="78x98">78X98</option><option value="78x118">78X118</option><option value="78x140">78X140</option><option value="114x118">114X118</option><option value="114x140">114X140</option><option value="134x98">134X98</option><option value="134x140">134X140</option> </select>
					</td>
					<td>
						<select id="vitrageFenetre2" name="vitrageFenetre2" style="font-size:9px"><option>Vitrage</option><option value="Standard">Standard</option><option value="Confort">Confort</option><option value="Tout confort">Tout confort</option> </select>
					</td>
					<td>
						<select id="finitionFenetre2" name="finitionFenetre2" style="font-size:9.4px;width:150px;"><option>Finition</option><option value="Bois vernis TopFinish">Bois vernis TopFinish</option><option>Coque blanche sans entretien</option> </select>
					</td>
					<td>
						<select name="ouvertureFenetre2" style="font-size:9.4px;"><option>Type ouverture</option><option>rotation</option><option>projection</option><option>motoris&eacute;</option> </select>
					</td>
					<td>
						<select name="tuileFenetre2" style="font-size:9.4px;width:100px;"><option>Tuile</option><option>Petites tuiles plates</option><option>Tuiles m&eacute;caniques</option><option>Ardoise</option> </select>
					</td>
					<td>
						<select name="storeFenetre2" style="font-size:9.40px;"><option>Stores</option><option>Occultants</option><option>Tamisants</option><option>Pare-soleil</option><option>Moustiquaire</option> </select>
					</td>
					<td>
						<select name="voletFenetre2" style="font-size:9.4px;"><option>Volet</option><option>SSL</option><option>SML</option> </select>
					</td>
				</tr>
			</tbody>
		</table>
               <input id="BoutSubFormFenetre2" name="BoutSubFormFenetre2" style="font-size:9.4px;margin-left:595px;color:white;height:23px;" type="submit" value="rechercher" />
	</form>
</div>
Voici mon code php
<?php
if(isset($_POST['fenetre1Boutton']))
{
	if(!empty($_POST['fenetre1Nom']))
	{
		echo"<form name='FormBoutonRennomerfenetre1' id='FormBoutonRennomerfenetre1' action='http://localhost/alphacombles/test-formulaire-2' method='post' style='background-color:rgb(128,204,40);color:black;margin:0px auto;'>
			".$_POST['fenetre1Nom'].":<input style='width:200px;margin-left:5px;height:9.5px;font-size:9.4px' maxlength='100' type='text' name='fenetre1Nom' id='fenetre1Nom' placeholder='".$_POST['fenetre1Nom']."'> <input style='width:100px;margin-left:5px;height:20px;font-size:9.4px;' type='submit' name='fenetre1Boutton' id='fenetre1Boutton'value='rennommer'>
		</form>";
	}
	else{
		echo'<form name="FormBoutonRennomerfenetre1" id="FormBoutonRennomerfenetre1" action="http://localhost/alphacombles/test-formulaire-2" method="post" style="background-color:rgb(128,204,40);color:black;margin:0px auto;">
			fenetre 1:<input style="width:200px;margin-left:5px;height:9.5px;font-size:9.4px" maxlength="100" type="text" name="fenetre1Nom"id="fenetre1Nom" placeholder="chambre de Lya"> <input style="width:100px;margin-left:5px;height:20px;font-size:9.4px;" type="submit" name="fenetre1Boutton"id="fenetre1Boutton"value="rennommer">
		</form>';
	}
	
}
else
{
	if(isset($_POST['fenetre2Boutton'])){
		echo"<form name='FormBoutonRennomerfenetre1' id='FormBoutonRennomerfenetre1' action='http://localhost/alphacombles/test-formulaire-2' method='post' style='background-color:rgb(128,204,40);color:black;margin:0px auto;'>
			".$_POST['fenetre1Nom'].":<input style='width:200px;margin-left:5px;height:9.5px;font-size:9.4px' maxlength='100' type='text' name='fenetre1Nom' id='fenetre1Nom' placeholder='".$_POST['fenetre1Nom']."'> <input style='width:100px;margin-left:5px;height:20px;font-size:9.4px;' type='submit' name='fenetre1Boutton' id='fenetre1Boutton'value='rennommer'>
		</form>";
	}
	else{
		echo'<form name="FormBoutonRennomerfenetre1" id="FormBoutonRennomerfenetre1" action="http://localhost/alphacombles/test-formulaire-2" method="post" style="background-color:rgb(128,204,40);color:black;margin:0px auto;">
			fenetre 1:<input style="width:200px;margin-left:5px;height:9.5px;font-size:9.4px" maxlength="100" type="text" name="fenetre1Nom"id="fenetre1Nom" placeholder="chambre de Lya"> <input style="width:100px;margin-left:5px;height:20px;font-size:9.4px;" type="submit" name="fenetre1Boutton"id="fenetre1Boutton"value="rennommer">
		</form>';
	}
			
}

?>
En attente d'une réponse de votre part,veuillez recevoir mes sincères salutations.
Q.Tessier

Mammouth du PHP | 804 Messages

03 févr. 2014, 13:40

Bonjour,

si je peu me permettre, afin que ton code soit plus lisible utilise les CSS, ensuite ton problème peut se résoudre en utilisant deux méthodes, soit ajax -> javascripts, soit les variables sessions PHP.

Ton problème vient du fais que quand tu clique sur le deuxième bouton tu rafraîchie ta page et du coup tu perd les données de ton premier formulaire.

en plus je pense que ce sera plus claire à faire

dog

Petit nouveau ! | 2 Messages

03 févr. 2014, 16:53

merci de ta réponse dogmongo.