Ma variable _SESSION n'est pas la bonne

Fermé
Marc - Modifié par Marc le 20/06/2016 à 10:16
 Marc - 21 juin 2016 à 08:37
Bonjour,

Je demande votre aide, car depuis quelques jours je suis bloqué dans mon formulaire de modification de pointage.
Sur une première page, je demande la saisie de la période grace à un select qui va chercher les valeurs dans ma bdd.

Dans ma deuxième page elle est sensé affiché les valeurs correspondantes à la période.

Or elle m'affiche seulement les variables de ma dernière période affiché dans ma bdd.

Code page n°1:
          <form method="POST" action="modif2_pointage_inter.php">
<?php
include("../connexion.php");
$login=$_SESSION['login'];
echo "<select id='date_point' classe='date_point' name='date_point'>";
$date_point = $connexion->query("SELECT * FROM pointages_brouillon Where login='$login';");
foreach ($date_point as $dp)
{
echo '<option id="dp" name="dp" value='.$dp["date"].'>'.$dp["datedebut"].' '. au.' ' .$dp["datefin"].' </option>';
}
$datedebut=$dp["datedebut"];
$datefin=$dp["datefin"];
$_SESSION['datedebut']=$datedebut;
$_SESSION['datefin']=$datefin;
echo"<br/> ";
echo'</select>';
?>

<?php
echo "<input type='submit' value='Rechercher' " ;
?>

Extrait du code page n°2

<td class="tg-yw4l" id="nprojet"> <?php
$nprojet = $connexion->query("SELECT nprojet FROM pointages_brouillon Where login='$login' and datedebut='$datedebut' and datefin='$datefin'");
foreach ($nprojet as $np)
{
echo '<input type="text" class="nprojet" name="nprojet" size="5" value='.$np["nprojet"].'>';
}
echo"<br/> " ?>
etc...

4 réponses

jordane45 Messages postés 38145 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 25 avril 2024 4 650
20 juin 2016 à 12:11
Bonjour,

Là... dans ton code actuel ... tes variables de session correspondent aux dernières valeurs de ta boucle (celle que tu utilises pour créer tes "options".
En aucun cas elle ne contiennent le choix réaliser lors du submit de ton formulaire :!!

Dans ton fichier modif2_pointage_inter.php tu ne peux, en l'état actuel de ton code, que récupérer la valeur de ton select : 'date_point'
de la façon suivante :
$date_point = isset($_POST['date_point']) ? $_POST['date_point'] : NULL;

qui correspondant à la valeur de $dp["date"] (que tu as placé dans ton "value".)





1
Merci de votre aide, je viens d'affecter mes variables datedebut et datefin à ma variable date_point, mais lorsque je fais un echo pour afficher la variable date_point rien ne s'affiche, et dans mon tableau c'est toujours les dernières valeurs saisis dans ma bdd qui s'affiche, je ne comprend pas.

J'ai modifié ceci:
                <td class="tg-yw4l" id="nprojet"> <?php                              
$nprojet = $connexion->query("SELECT nprojet FROM pointages_brouillon Where login='$login' and date_point='$date_point'");
foreach ($nprojet as $np)
{
echo '<input type="text" class="nprojet" name="nprojet" size="5" value='.$np["nprojet"].'>';
}
echo"<br/> " ?>


Ainsi que :
                        <?php 
include("../connexion.php");
$login=$_SESSION['login'];
$date_point = isset($_POST['date_point']) ? $_POST['date_point'] : NULL;

?>
0
jordane45 Messages postés 38145 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 25 avril 2024 4 650
20 juin 2016 à 19:08
Il faudrait que tu nous montres le code dans son intégralité. ... et que tu nous précises le nom des fichiers correspondant
0
Pitet Messages postés 2826 Date d'inscription lundi 11 février 2013 Statut Membre Dernière intervention 21 juillet 2022 524
20 juin 2016 à 10:21
Salut,

Comment sont définies les variables $datedebut et $datefin sur la page 2 ?
Ne devraient-elles pas être définis via $_POST['dp'] ?

Bonne journée
0
Je les ai définit comme ceci: " <?php
include("../connexion.php");
$login=$_SESSION['login'];
$datedebut=$_SESSION["datedebut"];
$datefin=$_SESSION["datefin"];
?> "
Merci d'avance de l'attention porter à mon problème.
0
Comment récupéré la variable date_point et ensuite afficher les données correspondantes dans mon modif2_pointage_inter.php
Je commence à bien sécher là par contre, car je ne vois pas du tout comment faire...
0
Donc pour le code dans son intégralité:

modif_pointage_inter.php (fichier où je choisis la période) :

 <?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="../style/style.css" />
<link rel="stylesheet" href="../style/style_menu.css" />
<title>Accueil</title>
</head>

<body>
<?php include("header_inter.php"); ?>


<div id="connexion2">
<h1> Modification d'un formulaire de pointage </h1>
</div>

<p> </p>

<fieldset>
<legend> Modification d'un formulaire de pointage </legend>
Pour la période du
<form method="POST" action="modif2_pointage_inter.php">
<?php
include("../connexion.php"); // Appel de la page connexion.php
$login=$_SESSION['login']; // Fixe la variable Login qui est en session, en variable
echo "<select id='date_point' classe='date_point' name='date_point'>";
$date_pointage = $connexion->query("SELECT * FROM pointages_brouillon Where login='$login';"); // Selection de tous les élements de la table pointages_brouillon où la session en cours a écrit par la même session
foreach ($date_pointage as $dp)
{
echo '<option id="dp" name="dp" value='.$dp["id"].'>'.$dp["datedebut"].' '. au.' ' .$dp["datefin"].' </option>'; // Affiche les dates début au date finale
}

echo"<br/> ";
echo'</select>';
?>
<?php
echo "<input type='submit' value='Rechercher' " ;
?>


<div class="tg-wrap"><table id="tg-oAe8e" class="tg">
<thead><tr>
<th class="tg-yw4l">n° projet </th>
<th class="tg-yw4l">Libelle</th>
<th class="tg-baqh" colspan="4">Lundi</th>
<th class="tg-baqh" colspan="4">Mardi</th>
<th class="tg-baqh" colspan="4">Mercredi</th>
<th class="tg-baqh" colspan="4">Jeudi</th>
<th class="tg-baqh" colspan="4">Vendredi</th>
</tr>

<tr>
<td class="tg-5xqe"></td>
<td class="tg-5xqe"></td>
<td class="tg-baqh">DDC</td>
<td class="tg-baqh">DCC</td>
<td class="tg-baqh">Heures réalisées</td>
<td class="tg-baqh">Dont de nuit</td>
<td class="tg-baqh">DDC</td>
<td class="tg-baqh">DCC</td>
<td class="tg-baqh">Heures réalisées</td>
<td class="tg-baqh">Dont de nuit</td>
<td class="tg-baqh">DDC</td>
<td class="tg-baqh">DCC</td>
<td class="tg-baqh">Heures réalisées </td>
<td class="tg-baqh">Dont de nuit</td>
<td class="tg-baqh">DDC</td>
<td class="tg-baqh">DCC</td>
<td class="tg-baqh">Heures réalisées</td>
<td class="tg-baqh">Dont de nuit</td>
<td class="tg-baqh">DDC</td>
<td class="tg-baqh">DCC</td>
<td class="tg-baqh">Heures réalisées</td>
<td class="tg-baqh">Dont de nuit</td>
<td class="tg-baqh">Chef d'équipe</td>

</tr> </thead>
<tr id="contenaire">
<br/>
<td class="tg-yw4l" id="nprojet">
<td class="tg-yw4l" id="nom_lieu_chantier"></td>
<td class="tg-yw4l" id="ddclundi"></td>
<td class="tg-yw4l" id="dcclundi"></td>
<td class="tg-yw4l" id="hlundi"></td>
<td class="tg-yw4l" id="hlundisoir"></td>
<td class="tg-yw4l" id="ddcmardi"></td>
<td class="tg-yw4l" id="dccmardi"></td>
<td class="tg-yw4l" id="hmardi"></td>
<td class="tg-yw4l" id="hmardisoir"></td>
<td class="tg-yw4l" id="ddcmercredi"></td>
<td class="tg-yw4l" id="dccmercredi"></td>
<td class="tg-yw4l" id="hmercredi"></td>
<td class="tg-yw4l" id="hmercredisoir"></td>
<td class="tg-yw4l" id="ddcjeudi"></td>
<td class="tg-yw4l" id="dccjeudi"></td>
<td class="tg-yw4l" id="hjeudi"></td>
<td class="tg-yw4l" id="hjeudisoir"></td>
<td class="tg-yw4l" id="ddcvendredi"></td>
<td class="tg-yw4l" id="dccvendredi"></td>
<td class="tg-yw4l" id="hvendredi"></td>
<td class="tg-yw4l" id="hvendredisoir"></td> <br/>
<td class="tg-yw4l" id="chefequipe"></td> <br/>
</tr>
</table>
</div>
</form>
</fieldset>
</body>
</html>


modif2_pointage_inter.php (fichier appelé une fois la période choisis, et qui complete le tableau avec les valeurs de la bdd) :

 <?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="../style/style.css" />
<link rel="stylesheet" href="../style/style_menu.css" />
<title>Accueil</title>

<?php
include("../connexion.php");
$login=$_SESSION['login'];

$date_point = isset($_request['date_point']) ? $_request['date_point'] : NULL;

?>
</head>

<body>
<?php include("header_inter.php"); ?>


<div id="connexion2">
<h1> Modification d'un formulaire de pointage </h1>
</div>

<p> </p>

<fieldset>
<legend> Modification d'un formulaire de pointage </legend>
test : <?php echo"$date_point" ?>



<div class="tg-wrap"><table id="tg-oAe8e" class="tg">
<thead><tr>
<th class="tg-yw4l">n° projet </th>
<th class="tg-yw4l">Libelle</th>
<th class="tg-baqh" colspan="4">Lundi</th>
<th class="tg-baqh" colspan="4">Mardi</th>
<th class="tg-baqh" colspan="4">Mercredi</th>
<th class="tg-baqh" colspan="4">Jeudi</th>
<th class="tg-baqh" colspan="4">Vendredi</th>
</tr>

<tr>
<td class="tg-5xqe"></td>
<td class="tg-5xqe"></td>
<td class="tg-baqh">DDC</td>
<td class="tg-baqh">DCC</td>
<td class="tg-baqh">Heures réalisées</td>
<td class="tg-baqh">Dont de nuit</td>
<td class="tg-baqh">DDC</td>
<td class="tg-baqh">DCC</td>
<td class="tg-baqh">Heures réalisées</td>
<td class="tg-baqh">Dont de nuit</td>
<td class="tg-baqh">DDC</td>
<td class="tg-baqh">DCC</td>
<td class="tg-baqh">Heures réalisées </td>
<td class="tg-baqh">Dont de nuit</td>
<td class="tg-baqh">DDC</td>
<td class="tg-baqh">DCC</td>
<td class="tg-baqh">Heures réalisées</td>
<td class="tg-baqh">Dont de nuit</td>
<td class="tg-baqh">DDC</td>
<td class="tg-baqh">DCC</td>
<td class="tg-baqh">Heures réalisées</td>
<td class="tg-baqh">Dont de nuit</td>
<td class="tg-baqh">Chef d'équipe</td>

</tr> </thead>
<tr id="contenaire">
<br/>
<td class="tg-yw4l" id="nprojet"> <?php
$nprojet = $connexion->query("SELECT nprojet FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($nprojet as $np)
{
echo '<input type="text" class="nprojet" name="nprojet" size="5" value='.$np["nprojet"].'>';
}
echo"<br/> " ?>
<td class="tg-yw4l" id="nom_lieu_chantier"><?php
$libelle = $connexion->query("SELECT nom_lieu_chantier FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($libelle as $lbl)
{
echo '<input type="text" class="nprojet" name="nprojet" size="5" value='.$lbl["nom_lieu_chantier"].'>';
} ?>
<td class="tg-yw4l" id="ddclundi"><?php
$ddclundi= $connexion->query("SELECT ddclundi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($ddclundi as $ddcl)
{
echo '<input type="text" class="ddclundi" name="ddclundi" size="5" value='.$ddcl["ddclundi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="dcclundi"><?php
$dcclundi= $connexion->query("SELECT dcclundi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($dcclundi as $dccl)
{
echo '<input type="text" class="dcclundi" name="dcclundi" size="5" value='.$dccl["dcclundi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="hlundi"><?php
$hlundi= $connexion->query("SELECT hlundi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($hlundi as $hl)
{
echo '<input type="text" class="hlundi" name="hlundi" size="5" value='.$hl["hlundi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="hlundisoir"><?php
$hlundisoir= $connexion->query("SELECT hlundisoir FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($hlundisoir as $hls)
{
echo '<input type="text" class="hlundisoir" name="hlundisoir" size="5" value='.$hls["hlundisoir"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="ddcmardi"><?php
$ddcmardi= $connexion->query("SELECT ddcmardi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($ddcmardi as $ddcm)
{
echo '<input type="text" class="ddcmardi" name="ddcmardi" size="5" value='.$ddcm["ddcmardi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="dccmardi"><?php
$dccmardi= $connexion->query("SELECT dccmardi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($dccmardi as $dccm)
{
echo '<input type="text" class="dcclundi" name="dcclundi" size="5" value='.$dccm["dccmardi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="hmardi"><?php
$hmardi= $connexion->query("SELECT hmardi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($hmardi as $hma)
{
echo '<input type="text" class="hmardi" name="hmardi" size="5" value='.$hma["hmardi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="hmardisoir"><?php
$hmardisoir= $connexion->query("SELECT hmardisoir FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($hmardisoir as $hmas)
{
echo '<input type="text" class="hmardisoir" name="hmardisoir" size="5" value='.$hmas["hmardisoir"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="ddcmercredi"><?php
$ddcmercredi= $connexion->query("SELECT ddcmercredi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($ddcmercredi as $ddcme)
{
echo '<input type="text" class="ddcmercredi" name="ddcmercredi" size="5" value='.$ddcme["ddcmercredi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="dccmercredi"><?php
$dccmercredi= $connexion->query("SELECT dccmercredi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($dccmercredi as $dccme)
{
echo '<input type="text" class="dccmercredi" name="dccmercredi" size="5" value='.$dccme["dccmercredi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="hmercredi"><?php
$hmercredi= $connexion->query("SELECT hmercredi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($hmercredi as $hme)
{
echo '<input type="text" class="hmercredi" name="hmercredi" size="5" value='.$hme["hmercredi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="hmercredisoir"><?php
$hmercredisoir= $connexion->query("SELECT hmercredisoir FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($hmercredisoir as $hmes)
{
echo '<input type="text" class="hmercredisoir" name="hmercredisoir" size="5" value='.$hmes["hmercredisoir"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="ddcjeudi"><?php
$ddcjeudi= $connexion->query("SELECT ddcjeudi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($ddcjeudi as $ddcj)
{
echo '<input type="text" class="ddcjeudi" name="ddcjeudi" size="5" value='.$ddcj["ddcjeudi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="dccjeudi"><?php
$dccjeudi= $connexion->query("SELECT dccjeudi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($dccjeudi as $dccj)
{
echo '<input type="text" class="dccjeudi" name="dccjeudi" size="5" value='.$dccj["dccjeudi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="hjeudi"><?php
$hjeudi= $connexion->query("SELECT hjeudi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($hjeudi as $hj)
{
echo '<input type="text" class="hjeudi" name="hjeudi" size="5" value='.$hj["hjeudi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="hjeudisoir"><?php
$hjeudisoir= $connexion->query("SELECT hjeudisoir FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($hjeudisoir as $hjs)
{
echo '<input type="text" class="hjeudisoir" name="hjeudisoir" size="5" value='.$hjs["hjeudisoir"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="ddcvendredi"><?php
$ddcvendredi= $connexion->query("SELECT ddcvendredi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($ddcvendredi as $ddcv)
{
echo '<input type="text" class="ddcvendredi" name="ddcvendredi" size="5" value='.$ddcv["ddcvendredi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="dccvendredi"><?php
$dccvendredi= $connexion->query("SELECT dccvendredi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($dccvendredi as $dccv)
{
echo '<input type="text" class="dccvendredi" name="dccvendredi" size="5" value='.$dccv["dccvendredi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="hvendredi"><?php
$hvendredi= $connexion->query("SELECT hvendredi FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($hvendredi as $hv)
{
echo '<input type="text" class="hvendredi" name="hvendredi" size="5" value='.$hv["hvendredi"].'>';
}
echo"<br/> " ?></td>
<td class="tg-yw4l" id="hvendredisoir"><?php
$hvendredisoir= $connexion->query("SELECT hvendredisoir FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($hvendredisoir as $hvs)
{
echo '<input type="text" class="hvendredisoir" name="hvendredisoir" size="5" value='.$hvs["hvendredisoir"].'>';
}
echo"<br/> " ?></td> <br/>
<td class="tg-yw4l" id="chefequipe"><?php
$chef_equipe= $connexion->query("SELECT chef_equipe FROM pointages_brouillon Where login='$login' and date_point='$date_point';");
foreach ($chef_equipe as $ce)
{
echo '<input type="text" class="chef_equipe" name="chef_equipe" size="5" value='.$ce["chef_equipe"].'>';
}
echo"<br/> " ?></td> <br/>


</tr>
</table>
</div>
</form>
</fieldset>
</body>
</html>
0
jordane45 Messages postés 38145 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 25 avril 2024 4 650
21 juin 2016 à 08:35
Dans ta table pointage_brouillon... à quoi correspond le champe date_point ... un id ou une date ?

...car dans ta liste déroulante. .. c'est l'id du pointage que tu retournes....
0
Elle correspond à un id par exemple si la date du début est : "21/06/2016" et la date de fin est "28/06/2016" dans date_point il sera marqué 210616280616.

Merci de votre aide en tout cas.
0