Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & MySQL
PHP & MySQL Forum d'entraide sur les fonctions MySQL avec PHP. Avant de poster -> FAQ MySQL, Cours MySQL et Sources MySQL. Pour les questions concernant le moteur MySQL plutôt que les fonctions PHP, merci d'utiliser le forum MySQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 30/06/2011, 20h13   #1
 
Homme khmaies guesmi
Étudiant
Inscription : avril 2011
Messages : 63
Détails du profil
Informations personnelles :
Nom : Homme khmaies guesmi
Localisation : Tunisie

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : avril 2011
Messages : 63
Points : -3
Points : -3
Par défaut un probleme de placement

Bonjours,

je suis debutant en php,et j'ai tomber sur une faute bete.
J'ai un script php, dont lequel je voudrai recuperer le nom,leprenom,la matricule et le service (j'ai fait une redirection) .mais lorsque j'ai fait l'exucution ces champs m'apparaissent en haut de la page , et nom dans les champs correspondant (nom,matrcule,prenom, service ,date)
SVP qui peut m'aider ,et ça sera trés synpa de sa coté..
voici mon code..

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
session_start();
include("connexion.php");
connect($host,$user,$mot_passe,$db_name);
if ( !session_is_registered("authen_user")){
#echo '<META HTTP-EQUIV="refresh" CONTENT="0;URL=index.php?erreur=404">';
#redirection instantanée
header("location:index.php?erreur=404");
}
//$date = date("d/m/Y à H\hi", filemtime($_SERVER['SCRIPT_FILENAME'])); 
$date = getdate();
$m = $date['mon'];
$j = $date['mday'];
$a = $date['year'];
$d= $j."/".$m."/".$a;
$sn=$GET['sn'];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link href="css/style.css" rel="stylesheet">
<title></title>
</head>
<body topmargin="0" leftmargin="0">
&nbsp;
<table width="967" height="902"  border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#111111" bgcolor="#FFFFFF" style="border-collapse: collapse">
<tr>
    <td width="100%" height="126" align="left" valign="top">
         <table WIDTH="967" BORDER="0" CELLPADDING="0" CELLSPACING="0">
            <tr>
                <td COLSPAN="6"><img SRC="img/header.jpg" WIDTH="387" HEIGHT="94"></td>
           </tr>
	       <tr>
             <td width="89"><a class="linx" href="user_home.php">Consultation  </a></td>
                <td width="111"><a class="linx" href="new.php">Ajouter nouveau</a></td>
                <td width="467"><a class="linx" href="find2.php">Recherche</a></td>
             <td width="38"><a class="linx" href=""></a></td>
               <td width="175"><a class="linx" href="#6"></a></td>
               <td width="87"><a class="linx" href="deco.php">D&eacute;connecxion</a></td>
          </tr>
		   <?php
 
	   $sql="select * from pc where n_serie='$sn' ";
	   $rs=mysql_query("$sql");
	   $i=1;
	   $query = "SELECT count(id) from pc where  n_serie='$sn' ";
       $result = mysql_query($query) or die (mysql_error());
       $resultat=mysql_fetch_row($result);
       echo "nbre est :       $resultat[0]";
	   echo "<br />";
	   echo "<br />";
	   while($tab=mysql_fetch_array($rs))
	   { 
echo "<tr>";
         echo "<td valign=top><p class=text2> $tab[0]</td>";
	     echo "<td valign=top><p class=text2> $tab[1]</td>";
		 echo "<td valign=top><p class=text2> $tab[11]</td>";
		 echo "<td valign=top><p class=text2> $tab[12]</td>";
	     echo "<td valign=top><p class=text2> $tab[3]</td>";
	     echo "<td valign=top><p class=text2> $tab[4]</td>";
	     echo "<td valign=top><p class=text2> $tab[5]</td>";
	     echo "<td valign=top><p class=text2> $tab[6]</td>";
	     echo "<td valign=top><p class=text2> $tab[8]</td>";
	     echo "<td valign=top><p class=text2> $tab[10]</td>";
		 }
		 ?>
		  <tr>
		    <td COLSPAN="6">&nbsp;</td>
		   </tr>
      </table>
    </td>
</tr>
 <td  valign="top"><hr>
	 <table width="966" height="227"  BORDER="0" CELLPADDING="0" CELLSPACING="0" bordercolor="#BDE7F7">
	   <tr>
	     <th height="33" ><p align="left" class=text2>Réaffectation de PC </th>
	   </tr>
	   <tr>
	     <td height="125" align="center">
		 <table width="335" height="105">
		 <form name="f2" action="affect2.php" method="post">
		 <input type="hidden" value="<?php echo $id; ?>" name="id">
		 <tr><td width="128"><span class="Style1"> Nom :</span></td> 
		 <td width="195"><input name="nom"></td></tr>
		 <tr><td><span class="Style1"> Prénom :</span></td> <td><input name="pre"></td></tr>
		 <tr><td><span class="Style1"> Matricule :</span></td> <td><input name="mat"></td></tr>
		 <tr><td><span class="Style1"> Services :</span></td> <td><input name="serv"></td></tr>
		 </td></tr>
		  <tr><td><span class="Style1"> Date : </span></td> <td><?php echo $d; ?></td></tr>
		 <tr>
		     <label></label></td></tr>
			  <tr><td height="52"><input type="submit" value="Valider" ></td>
		  <td><input type="reset" value="Annuler"></td></tr>
 
</form>
</table>
		 </td>
	   </tr>
	 </table>
 
    </td>	   
</tr>
</table>
		<?php
		if ( isset($_POST['Nom'])&&  isset($_POST['Prénom'])  &&  isset($_POST['Matricule'])  &&  
		isset($_POST['Service'])   &&  isset($_POST['Date'])  )
		{
 
			//enregistrer les modifications de l'evenement concerné*/
	  $req=$bdd->prepare("UPDATE evenement SET 
	  Nom=:$tab[nom],
	  Prenom=:$tab[prenom],
	  Matricule=:$tab[prenom],
	  Date=:$tab[date],
	  Service=:$tab[service]
	  WHERE n_serie='$sn' ");
    <tr><td><span class="Style1"> Prénom :</span></td> <td><input name="pre" value="$tab[prenom]"</td></tr>
		 <tr><td><span class="Style1"> Matricule :</span></td> <td><input name="mat" value="$tab[matricule]"></td></tr>
		 <tr><td><span class="Style1"> Services :</span></td> <td><input name="serv" value="$tab[service]"></td></tr>	  
	  </td></tr>
	if ($req){
	echo "votre réaffectation  est prise en compte!";
	}
   }	
   ?>
</body>
</head>
</html>
pfakhmaies est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2011, 21h13   #2
Invité de passage
 
Femme
Étudiant
Inscription : juin 2011
Messages : 28
Détails du profil
Informations personnelles :
Sexe : Femme
Localisation : France

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : juin 2011
Messages : 28
Points : 4
Points : 4
Bonjour,
Déjà, sur le site il existe des balises [code] pour afficher ton code en couleur, ça nous évite d'avoir à nous arracher les yeux pour essayer de trouver l'erreur. Aussi, je ne sais pas si ton code est comme ça dans tes fichiers mais je pense que tu t'y retrouverais mieux en indentant un peu plus.
Ensuite, j'ai remarqué qu'il manque pas mal de fermeture de balises HTML. En indentant, tu vois facilement ce genre d'erreur ! Et enfin pour faire de la mise en page générale tu devrais utiliser des <div> plutôt que des <table> qui ne sont pas du tout fait pour ça. Pour les formulaires, tu peux utiliser des <label> pour centrer tout comme il faut sans <table>. Je sais que tu débutes, c'est pour ça que je me permets de te donner ces conseils, que tu commences à coder comme un vrai développeur web digne de ce nom

Sinon pour ton problème, comme c'est un peu tout mélangé, j'ai eu du mal à voir d'où l'erreur venait exactement. Mais il y a des choses que tu essayer de corriger comme ici (regarde les commentaires que j'ai ajouté au code) :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
req=$bdd->prepare("UPDATE evenement SET // Début de la chaine
Nom=:$tab[nom],
Prenom=:$tab[prenom],
Matricule=:$tab[prenom],
Date=:$tab[date],
Service=:$tab[service]
WHERE n_serie='$sn' "); // Fin de la chaine
// En dessous on est censé être en HTML mais tu n'as pas fermé la balise PHP
<tr><td><span class="Style1"> Prénom :</span></td> <td><input name="pre" value="$tab[prenom]"</td></tr>
<tr><td><span class="Style1"> Matricule :</span></td> <td><input name="mat" value="$tab[matricule]"></td></tr>
<tr><td><span class="Style1"> Services :</span></td> <td><input name="serv" value="$tab[service]"></td></tr>	
</td></tr>
Il y a encore autre chose. Je suppose que ton formulaire rappelle cette même page pour effectuer le traitement des données saisies. Ce que tu récupères en PHP ce sont les name de tes champs et non ce que tu affiches. Tu dois donc récupérer $_POST['pre'], $_POST['mat'], etc. ici :
Code :
1
2
3
if ( isset($_POST['Nom'])&& isset($_POST['Prénom']) && isset($_POST['Matricule']) && 
isset($_POST['Service']) && isset($_POST['Date']) )
{
Weirdy est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/06/2011, 22h13   #3
 
Homme khmaies guesmi
Étudiant
Inscription : avril 2011
Messages : 63
Détails du profil
Informations personnelles :
Nom : Homme khmaies guesmi
Localisation : Tunisie

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : avril 2011
Messages : 63
Points : -3
Points : -3
bonjours ,
merci boco, je vais essayer de corriger
pfakhmaies est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/07/2011, 00h46   #4
 
Homme khmaies guesmi
Étudiant
Inscription : avril 2011
Messages : 63
Détails du profil
Informations personnelles :
Nom : Homme khmaies guesmi
Localisation : Tunisie

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : avril 2011
Messages : 63
Points : -3
Points : -3
bonjours monsieurs,

SVP , dsl , je n'arrive pas à resoudre le probleme, j'ai changé mon code, mais rien a changé.En faite , dans ce script je voudrais récuperer ($tab[4]=Nom, ($tab[5]=prenom,$tab[6]=Matricule, $tab[7]=service)
et merci d'avance
voici le code :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
 
<?php
session_start();
include("connexion.php");
connect($host,$user,$mot_passe,$db_name);
if ( !session_is_registered("authen_user")){
#echo '<META HTTP-EQUIV="refresh" CONTENT="0;URL=index.php?erreur=404">';
#redirection instantanée
header("location:index.php?erreur=404");
}
//$date = date("d/m/Y à H\hi", filemtime($_SERVER['SCRIPT_FILENAME'])); 
$date = getdate();
$m = $date['mon'];
$j = $date['mday'];
$a = $date['year'];
$d= $j."/".$m."/".$a;
$sn=$_POST['sn'];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link href="css/style.css" rel="stylesheet">
<title></title>
</head>
<body topmargin="0" leftmargin="0">
&nbsp;
<table width="967" height="902"  border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#111111" bgcolor="#FFFFFF" style="border-collapse: collapse">
<tr>
    <td width="100%" height="126" align="left" valign="top">
         <table WIDTH="967" BORDER="0" CELLPADDING="0" CELLSPACING="0">
            <tr>
                <td COLSPAN="6"><img SRC="img/header.jpg" WIDTH="387" HEIGHT="94"></td>
           </tr>
	       <tr>
             <td width="89"><a class="linx" href="user_home.php">Consultation  </a></td>
                <td width="111"><a class="linx" href="new.php">Ajouter nouveau</a></td>
                <td width="467"><a class="linx" href="find2.php">Recherche</a></td>
             <td width="38"><a class="linx" href=""></a></td>
               <td width="175"><a class="linx" href="#6"></a></td>
               <td width="87"><a class="linx" href="deco.php">D&eacute;connecxion</a></td>
          </tr>
		   <?php
 
	   $sql="select * from pc where n_serie='$sn' ";
	   $rs=mysql_query("$sql");
	   $i=1;
	   $query = "SELECT count(id) from pc where  n_serie='$sn' ";
       $result = mysql_query($query) or die (mysql_error());
       $resultat=mysql_fetch_row($result);
 
       //echo "nbre est :       $resultat[0]";
	   //echo "<br />";
	   //echo "<br />";
	   while($tab=mysql_fetch_array($rs))
	   { 
echo "<tr>";
         echo "<td valign=top><p class=text2> $tab[0]</td>";
	     echo "<td valign=top><p class=text2> $tab[1]</td>";
		 echo "<td valign=top><p class=text2> $tab[11]</td>";
		 echo "<td valign=top><p class=text2> $tab[12]</td>";
	     echo "<td valign=top><p class=text2> $tab[3]</td>";
	     echo "<td valign=top><p class=text2> $tab[4]</td>";
	     echo "<td valign=top><p class=text2> $tab[5]</td>";
	     echo "<td valign=top><p class=text2> $tab[6]</td>";
	     echo "<td valign=top><p class=text2> $tab[8]</td>";
	     echo "<td valign=top><p class=text2> $tab[10]</td>";
		 }
		 ?>
		  <tr>
		    <td COLSPAN="6">&nbsp;</td>
		   </tr>
      </table>
    </td>
</tr>
   <?php
 
	   $sql="select * from pc where n_serie='$sn' ";
	   $rs=mysql_query("$sql");
	   while($tab=mysql_fetch_array($rs)){
	   $Nom=$tab[1];
	   $Prenom=$tab[2];
	   $Service=$tab[3];
	   $Matricule=$tab[4];
	   }
	   ?>
 <td  valign="top"><hr>
	 <table width="966" height="227"  BORDER="0" CELLPADDING="0" CELLSPACING="0" bordercolor="#BDE7F7">
	   <tr>
	     <th height="33" ><p align="left" class=text2>Réaffectation de PC </th>
	   </tr>
	   <tr>
	     <td height="125" align="center">
		 <table width="335" height="105">
		 <form name="f2" action="affect2.php" method="post">
		 <input type="hidden" value="<?php echo $id; ?>" name="id">
		 <tr><td width="128"><span class="Style1"> Nom :</span></td> 
		 <td width="195"><input name="nom"  value="$Nom"></td></tr>
		 <tr><td><span class="Style1"> Prénom :</span></td> <td><input name="pre" value="$Prenom"></td></tr>
		 <tr><td><span class="Style1"> Matricule :</span></td> <td><input name="mat" value="$Matricule"></td></tr>
		 <tr><td><span class="Style1"> Services :</span></td> <td><input name="serv" value="$Service"></td></tr>
		 </td></tr>
		  <tr><td><span class="Style1"> Date : </span></td> <td><?php echo $d; ?></td></tr>
		 <tr>
		     <label></label></td></tr>
			  <tr><td height="52"><input type="submit" value="Valider" ></td>
		  <td><input type="reset" value="Annuler"></td></tr>
</form>
</table>
		 </td>
	   </tr>
	 </table>
 
    </td>	   
</tr>
</table>
		<?php
		if ( isset($_POST['Nom'])&&  isset($_POST['Prénom'])  &&  isset($_POST['Matricule'])  &&  
		isset($_POST['Service'])   &&  isset($_POST['Date'])  )
		{
 
			//enregistrer les modifications de l'evenement concerné*/
	  $req=$bdd->prepare("UPDATE evenement SET 
	  Nom=:$tab[nom],
	  Prenom=:$tab[prenom],
	  Matricule=:$tab[prenom],
	  Date=:$tab[date],
	  Service=:$tab[service]
	  WHERE n_serie='$sn' ");
	  }
	  ?>
         <tr><td><span class="Style1"> Prénom :</span></td> <td><input name="pre" value="$tab[prenom]"</td></tr>
		 <tr><td><span class="Style1"> Matricule :</span></td> <td><input name="mat" value="$tab[matricule]"></td></tr>
		 <tr><td><span class="Style1"> Services :</span></td> <td><input name="serv" value="$tab[service]"></td></tr>	  
	  </td></tr>	
</body>
</head>
</html>
pfakhmaies est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/07/2011, 09h34   #5
Membre confirmé
 
Avatar de Retrokiller069
 
Homme Bertrand
Étudiant
Inscription : octobre 2010
Messages : 216
Détails du profil
Informations personnelles :
Nom : Homme Bertrand
Localisation : France

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : octobre 2010
Messages : 216
Points : 268
Points : 268
Bonjour,

tu as fait une erreur de syntaxe au niveau des lignes 57 à 66. Il faut que tu écrives ceci:

Code :
1
2
 
echo "<td valign=top><p class=text2>".$tab[0]."</td>";
et là normalement ca marche
__________________
Ce n'est pas ce que nous voulons faire qui est impossible mais ce sont les moyens à sa mise en oeuvre qui peuvent le paraître

Ps: N'oubliez pas SVP
Retrokiller069 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 01/07/2011, 10h31   #6
 
Homme khmaies guesmi
Étudiant
Inscription : avril 2011
Messages : 63
Détails du profil
Informations personnelles :
Nom : Homme khmaies guesmi
Localisation : Tunisie

Informations professionnelles :
Activité : Étudiant
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : avril 2011
Messages : 63
Points : -3
Points : -3
bonjours,
merci , mais ,j'ai corrigé , mais avec votre proposition ,il n'apparait accune champs, c'est à dire je n'aurai pas meme les champs à remplir dans la page,

de plus, il m'apparit l'erreurs suivant:
Citation:
Notice: Undefined index: sn in c:\easyphp1-8\www\copie laptop\modifier.php on line 16
pfakhmaies est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 03h52.


 
 
 
 
Partenaires

Hébergement Web