FORMULAIRE CAPRICIEUX

Eléphant du PHP | 168 Messages

04 avr. 2005, 10:46

G 1 formulaire de mis a jour capricieux apres bien des pb pour le faire fonctionner g en fin trouvé la solution enfin presque il reste un champs qui ne se met pas a jour
es ce que quelqu'un peut me dire pourquoi?
Tous les hommes aspirent à être heureux, mais personne ne s'entend sur la définition du bonheur.
Celui qui a un ami véritable n'a pas besoin d'un miroir.

Eléphant du PHP | 168 Messages

04 avr. 2005, 10:50

je vais mettre mon code ca peut aider lol
il se passe sur trois pages
page 1
<html>
<head>
	<title></title>
</head>
<body>
<br>
<h2 align=center> MODIFIER UNE FICHE </H2>
<BR>
<form method="post" action="page5_2.php">
<?
include("sql.inc");
mysql_connect($nom_hote, $nom_utilisateur,$password);
$base=mysql_select_db("adresse");
if(!$base)
{
echo"impossible d ’ouvrir la base";
}?>
<table border="0" align=center width="330" CELLSPACING="0">
<tr><td width="50%">
<p>Quelle fiche ?</td>
<td width="126">
<?
echo"<form name=\"form\>";
echo"<p><select name=\"ligne\" size=\"1\">";
echo"<p><select name=\"ligne\" size=\"1\">";
$table=mysql_query("SELECT * FROM donnée");
while($ligne=mysql_fetch_object($table))
{
echo"<option value=\"$ligne->id\"> $ligne->user</option>";
}
echo"</select>";
//echo"</form1>";
?>
</td>
</tr>
<!--<tr><td width="135" height="27">
<p>Quelle donnée ?</td><td width="126" height"27>
<?
echo"<form name=\"form2\>";
echo"<p><select name=\"ligne2\" size=\"1\">";
echo"<p><select name=\"ligne2\" size=\"1\">";
$table=mysql_query("SELECT*FROM nom");
while($ligne2=mysql_fetch_object($table))
{
echo"<option value=\"$ligne->id\"> $ligne2->nom  </option>";
}
echo"</select>";
echo"</form2>";
?>
</td>
</tr>-->
<tr>
<td width="135" align=center>
<p><br></b><input type="submit" name="modifier" value="Modifier"></td>
<td width="126" align=center>
<p><br></b><input type="reset" name="annuler" value="Annuler"></td>
</tr>
</table><br>
<?
echo"<br>";
$lien1="./page2.php";
$text1="accueil";
$lien2="./index.php";
$text2="sortir";
echo"<table width=100%>";
echo"<tr>";
echo"<td width=25% align=left></td>";
echo"<td width=50% align=center>";
echo"<b><a href=\" $lien1\">$text1</a> <br /></b>";
echo"</td>";
echo"<td width=25% align=right>";
echo"<b><a href=\" $lien2\">$text2</a> <br /></b>";
echo"</td></tr></table>";
?>
</form>
</body>
</html>
page 2
<html>
<head>
	<title></title>
</head>
<body>
<br>
<h2 align=center> MODIFIER UNE FICHE </H2>
<form method="post" action="page5_3.php">
<?
$user=$_POST['ligne'];
echo "<h3>Vous voulez modifier la fiche correspondant aux données suivantes : </h3>";

Include("sql.inc");
mysql_connect($nom_hote, $nom_utilisateur,$password);
$base=mysql_select_db("adresse");
             if(!$base)
         {
        echo"connexion impossible";        
        }
		
$plus=0;

$table=mysql_query("select * from donnée where id='$user'");
echo"<table border=2 width=100%>";
echo"<tr>";
echo"<td align=center><b>Utilisateur";
echo"<td align=center><b>Machine";
echo"<td align=center><b>Vitesse";
echo"<td align=center><b>Adresse IP";
echo"<td align=center><b>Adresse MAC";
echo"<td align=center><b>Systeme D'exploitation";
echo"<td align=center><b>Localisation";

while ($ligne=mysql_fetch_object($table))
{
$plus=$plus+1;
$option="option['$plus']";
echo"<tr>";
echo"<td>$ligne->user</td>";
echo"<td>$ligne->machine</td>";
echo"<td>$ligne->vitesse Mbits/s</td> ";
echo"<td>$ligne->ip</td>";
echo"<td>$ligne->mac</td>";
echo"<td>$ligne->os</td>";
echo"<td>$ligne->localisation</td>";
}
echo"</tr></table>";

echo"<br>";

echo"<table border=0 align=center valign=top><tr><td width=135 height=27><p>
Utilisateur :</td><td width=126 height27 valign=bottom>";

echo"<p><br><form name=\"form\>";
echo"<select name=\"ligne\" size=\"1\">";
echo"<select name=\"ligne\" size=\"1\">";
$table=mysql_query("select * from donnée where id='$user'");
while($ligne=mysql_fetch_object($table))
{
echo"<option value=\"$ligne->id\"> $ligne->user   </option>";
}
echo"</select>";

echo"</td></tr>";

echo"<tr><td width=135 height=27><p>
Quel champs ?</td><td width=126 height27 valign=bottom>";

echo"<p><br><form name=\"form\>";
echo"<select name=\"ligne1\" size=\"1\">";
echo"<select name=\"ligne1\" size=\"1\">";
$table=mysql_query("select * from nom ");
while($ligne1=mysql_fetch_object($table))
{
echo"<option value=\"$ligne1->nom\"> $ligne1->nom   </option>";
}
echo"</select>";
echo"</td>
</tr>";

echo"<tr>
<td width=135>
<p>Nouvelle valeur :</td>
<td width=126>
<p><input type=text name=nouvelle valeur=''></td></tr>";

echo"<tr>
<td width=135 align=center>
<p><br></b><input type=submit name=modifier value=Modifier></td>
<td width=126 align=center>
<p><br></b><input type=reset name=annuler value=Annuler></td>
</tr>
</table>";

?>
    </form><p><br>
<?

$lien1="./page2.php";
$text1="accueil";
$lien2="./page5_1.php";
$text2="precedent";
$lien3="./index.php";
$text3="sortir";

echo"<table width=100%>";
echo"<tr>";
echo"<td width=25% align=left>";
echo"<b><a href=\" $lien2\">$text2</a></b>";

echo"</td>";
echo"<td width=50% align=center>";
echo"<b><a href=\" $lien1\">$text1</a></b>";
echo"</td>";
echo"<td width=25% align=right>";
echo"<b><a href=\" $lien3\">$text3</a></b>";
echo"</td></tr></table>";

?>
et enfin si vous avez suivi page... 3 (bien lol)
<?
$valeur=$_POST['nouvelle'];
$id=$_POST['ligne'];
$user=$_POST['ligne1'];
echo"$id";
echo "<h3>Modification effectués. Voici la nouvelle fiche : </h3>";

Include("sql.inc");
mysql_connect($nom_hote, $nom_utilisateur,$password);
$base=mysql_select_db("adresse");
             if(!$base)
         {
        echo"connexion impossible";
        }
		
$plus=0;
$table=mysql_query("update donnée set $user='$valeur' where id=$id");
$table=mysql_query("select * from donnée where id='$id'");
echo"<table border=2 width=100%>";
echo"<tr>";
echo"<td align=center><b>Utilisateur";
echo"<td align=center><b>Machine";
echo"<td align=center><b>Vitesse";
echo"<td align=center><b>Adresse IP";
echo"<td align=center><b>Adresse MAC";
echo"<td align=center><b>Systeme D'exploitation";
echo"<td align=center><b>Localisation";

while ($ligne=mysql_fetch_object($table))
{
$plus=$plus+1;
$option="option['$plus']";
echo"<tr>";
echo"<td>$ligne->user</td>";
echo"<td>$ligne->machine</td>";
echo"<td>$ligne->vitesse Mbits/s</td> ";
echo"<td>$ligne->ip</td>";
echo"<td>$ligne->mac</td>";
echo"<td>$ligne->os</td>";
echo"<td>$ligne->localisation</td>";
}
echo"</tr></table>";
?>
<p><br>
<?
$lien1="./page2.php";
$text1="accueil";
$lien2="./page5_1.php";
$text2="precedent";
$lien3="./index.php";
$text3="sortir";

echo"<table width=100%>";
echo"<tr>";
echo"<td width=25% align=left>";
echo"<b><a href=\" $lien2\">$text2</a></b>";

echo"</td>";
echo"<td width=50% align=center>";
echo"<b><a href=\" $lien1\">$text1</a></b>";
echo"</td>";
echo"<td width=25% align=right>";
echo"<b><a href=\" $lien3\">$text3</a></b>";
echo"</td></tr></table>";

?>
merci de votre aide
Tous les hommes aspirent à être heureux, mais personne ne s'entend sur la définition du bonheur.
Celui qui a un ami véritable n'a pas besoin d'un miroir.

Mammouth du PHP | 859 Messages

04 avr. 2005, 11:05

Ce code est ma foi bien long...Quel est le champ qui ne se remplit pas?

Eléphant du PHP | 168 Messages

04 avr. 2005, 11:12

tout les champs se remplisent
le probleme intervient dans la page 3 le champs utilisateur garde l'ancienne valeur alors que les autre se mettent bien a jour
Tous les hommes aspirent à être heureux, mais personne ne s'entend sur la définition du bonheur.
Celui qui a un ami véritable n'a pas besoin d'un miroir.

Mammouth du PHP | 859 Messages

04 avr. 2005, 11:27

Dans la page 2 tu as ça :

Code : Tout sélectionner

$table=mysql_query("select * from donnée where id='$user'");
et dans la page 3 tu as ça :

Code : Tout sélectionner

$table=mysql_query("select * from donnée where id='$id'");
tu es sûr qu'il ne faudrait pas mettre dans la page 3 id='$user' aussi?

Au passage, tu oublies de fermer des balises </td>, </tr>, </b>

Code : Tout sélectionner

echo"<tr>"; echo"<td align=center><b>Utilisateur"; echo"<td align=center><b>Machine"; echo"<td align=center><b>Vitesse"; echo"<td align=center><b>Adresse IP"; echo"<td align=center><b>Adresse MAC"; echo"<td align=center><b>Systeme D'exploitation"; echo"<td align=center><b>Localisation";

Eléphant du PHP | 168 Messages

04 avr. 2005, 11:49

meci de me signaler cette oublie de ma part
g trouvé mon erreur il avait une difference entre mes mots "utilisateur" (celui de la base de données et celui de la variable lol )
merci quand meme d'avoir jetté un coup d'oeil a mon pb
Tous les hommes aspirent à être heureux, mais personne ne s'entend sur la définition du bonheur.
Celui qui a un ami véritable n'a pas besoin d'un miroir.