Php

<?php>
session_start();
?>
<?php>
$login = $_SESSION['login'];
$text1 = 'Connexion';
if (empty($login) ){
$erreur = htmlentities('Problème de connexion veuillez vous connecter avant d\'avoir accès a l\'application. Merci de recommencer.');
echo '<br /><font color="#FF0000" size="4" weight="bold">'.$erreur.'</font>'.'<a href="index.php"><font size="3" weight="bold">'.$text1.'</a></font>';
}
?>

et voici le message qu'on m 'affiche quand j execute le code
Notice: Undefined index: login in C:\wamp\www\gestion-de-cheque\accueil.php on line 110

8 réponses

  1. au fait j'ai trouver d'ou venais le problème. c'est la variable $login que j ai créer elle na pas lieu d être.
    merci de m avoir aider.

    mais j aimerais savoir comment faitons pour genérer des fichiers a l extension .txt avec php
    1. Bonjour,

      Essayez ceci:

      $login = null;
      if(isset($_SESSION['login'])) {
          $login = $_SESSION['login'];  
      }
      

      A+
      1. Je n'ai toujours pas la ligne 110 de ton code ......

        Undefined index: login in C:\wamp\www\gestion-de-cheque\accueil.php on line 110

        Ce message signifie que le problème provient de la ligne 110 du code de la page accueil.php.

        Cordialement
        1. voici toi le code

          <?php
          session_start();
          ?>
          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml">
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
          <title>Acceuil</title>
          </head>
          <?php
          // On test bien que l'utilisateur c'est bien connecter car il aurait pu se connecter en tapant l'url sans se logger
          $login = $_SESSION['login'];
          $text = 'Menu';
          $text1 = 'Connexion';
          if (empty($login) ){
          $erreur = htmlentities('Problème de connexion veuillez vous connecter avant d\'avoir accès a l\'application. Merci de recommencer.');
          echo '<br /><font color="#FF0000" size="4" weight="bold">'.$erreur.'</font>'.'<a href="index.php"><font size="3" weight="bold">'.$text1.'</a></font>';
          }
          else {
          echo '<body>
          <div id="conteneur">
          <div id="head"><img src="images/logo.png" width="329" height="157" />
          <div id="bande">'.'</div>'.
          '<div id="heure">'.
          '</div>
          </div>'.
          '<div id="menu"><ul class="menu">
          <li><a href="accueil.php"><img src="images/bouton.png" width="100" height="32" />'.'</a></li>'.
          '<div id="position" align="right"><a href="fin_session.php"><img src="images/deco.png" width="100" height="30" />'.'</a></div>
          </ul>
          </div>'.
          '<div id="content">
          <br />
          <fieldset id="color"><legend class="Style3" id="co">'.$text.'</legend>'.
          ' <table width="88%" height="203" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
          <td width="36%" height="50" align="right" valign="bottom"><a href="agentmenu.php"><img src="images/boutons7.png" width="130" height="80" onMouseOver="javascript:this.src =\'images/boutons12.png\'" onMouseOut="javascript:this.src = \'images/boutons7.png\'">'.'</a></td>
          <td width="36%"></td>'.
          '<td width="36%" align="left" valign="bottom"><a href="banquemenu.php"><img src="images/boutons8.png" width="130" height="80" onMouseOver="javascript:this.src =\'images/boutons11.png\'" onMouseOut="javascript:this.src = \'images/boutons8.png\'" >'.'</a></td>
          </tr>'.
          '<tr>
          <td width="36%" height="50">'.'</td>'.
          '<td height="50" align="center" valign="middle"><a href="prestationmenu.php"><img src="images/boutons6.png" width="174" height="80" onMouseOver="javascript:this.src =\'images/boutons13.png\'" onMouseOut="javascript:this.src = \'images/boutons6.png\'">'.'</a></td>
          <td></td>
          </tr>'.
          '<tr>
          <td height="50" align="right" valign="top"><a href="chequemenu.php"><img src="images/bouton1.png" width="130" height="80" onMouseOver="javascript:this.src =\'images/boutons14.png\'" onMouseOut="javascript:this.src = \'images/bouton1.png\'">'.'</a></td>
          <td></td>'.
          '<td align="left" valign="top"><a href="clientsmenu.php"><img src="images/boutons9.png" width="130" height="80" onMouseOver="javascript:this.src =\'images/boutons10.png\'" onMouseOut="javascript:this.src = \'images/boutons9.png\'">'.'</a></td>
          </tr>
          </table>
          </fieldset>
          </div>'.
          '<div id="footer">
          <br clear="right" />'.'</div>
          </div>
          </body>';
          }
          ?>
          </html>
          1. Cette erreur apparaît lorsque vous utilisez les tableaux $_POST ou $_GET pour récupérer les variables de vos formulaires ou autres.

            Pour éviter cette erreur il suffit de tester si ce champs du tableau a été initialisé avec la fonction isset().

            Exemple pour une variable $_POST['truc']:
            // Avant d'utiliser $_POST['truc']
            if (isset($_POST['truc']))
            {
                      // Instructions si $_POST['truc'] existe
            }
            


            Si cela ne marche pas j'aurai besoin de votre code.
            Cordialement.
            1. Bonjour,

              1) Pourquoi effacer le "Bonjour" en entête du post ?
              2) L'erreur se trouve dans le fichier accueil.php à la ligne 110 !!! Rien à voir avec le code que tu indiques ...
              1. Bonjour,
                Pourrai-je avoir le code source jusqu'à la ligne 110 ?
                Car il semble que l'erreur provient de cette ligne.
                Cordialement.