IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

un probleme de placement


Sujet :

PHP & Base de données

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre actif
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

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

    Informations forums :
    Inscription : Avril 2011
    Messages : 65
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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>

  2. #2
    Membre actif
    Femme Profil pro
    Étudiant
    Inscrit en
    Juin 2011
    Messages
    32
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Juin 2011
    Messages : 32
    Par défaut
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    if ( isset($_POST['Nom'])&& isset($_POST['Prénom']) && isset($_POST['Matricule']) && 
    isset($_POST['Service']) && isset($_POST['Date']) )
    {

  3. #3
    Membre actif
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

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

    Informations forums :
    Inscription : Avril 2011
    Messages : 65
    Par défaut
    bonjours ,
    merci boco, je vais essayer de corriger

  4. #4
    Membre actif
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

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

    Informations forums :
    Inscription : Avril 2011
    Messages : 65
    Par défaut
    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 : Sélectionner tout - Visualiser dans une fenêtre à part
    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>

  5. #5
    Membre expérimenté Avatar de Retrokiller069
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2010
    Messages
    217
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2010
    Messages : 217
    Par défaut
    Bonjour,

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

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    echo "<td valign=top><p class=text2>".$tab[0]."</td>";
    et là normalement ca marche

  6. #6
    Membre actif
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

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

    Informations forums :
    Inscription : Avril 2011
    Messages : 65
    Par défaut
    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:
    Notice: Undefined index: sn in c:\easyphp1-8\www\copie laptop\modifier.php on line 16

Discussions similaires

  1. Probleme de placement de div
    Par KeKeMaN dans le forum Balisage (X)HTML et validation W3C
    Réponses: 15
    Dernier message: 31/05/2006, 17h57
  2. Problèmes de placement de div sous ie
    Par KeKeMaN dans le forum Balisage (X)HTML et validation W3C
    Réponses: 5
    Dernier message: 17/05/2006, 12h09
  3. [Debutant]Probleme de placement de JTree
    Par Mammuth dans le forum Composants
    Réponses: 4
    Dernier message: 15/11/2005, 13h49
  4. [debutant][Image]probleme de placement
    Par ehmppowa dans le forum Agents de placement/Fenêtres
    Réponses: 4
    Dernier message: 08/12/2004, 10h08
  5. probleme de placement
    Par ma_mat dans le forum Général JavaScript
    Réponses: 8
    Dernier message: 16/11/2004, 16h56

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo