-1

I have the following problem,

When I connect a user at my database, he doesn't remember the login. Indeed, I want to show the name of the member connected in my web page.

My code:

config.php

<?php
$connect = mysql_connect('localhost','root','aragorn11') or die ("erreur de connexion");
mysql_select_db('biblio',$connect) or die ("erreur de connexion base");
?>

session.php

<?php
session_start();
if (isset($_SESSION["login"])){
    $connected=1;
    $login=$_SESSION["login"];
}
?>  

And member.php

<?php 
include ("config.php"); 
include ("session.php"); 
?>
<!DOCTYPE html>
<html>
   <head>
     <meta charset="utf-8" />
     <title>Adherents_Connectés</title>
     <link rel="stylesheet" type="text/css" href="accueil.css" />
   </head>
   <body>   

<?php
  echo "<h4>Welcome : $login</h4>\n";
?>

    <h4> <a href = "index.html"> Déconnexion </a> <br/> </h4>


    <p> Liste des actions possibles pour un adherent de la bibliothèque est :
    <ul>
    <a href = "liste_dispo_adherents.php" > Consulter la liste des livres disponibles </a> 
    </ul>
    <ul>
    <a href = "emprunt.php" > Emprunter un livre </a> 
    </ul>
    </p>
</body>
</html>
Diemuzi
  • 3,507
  • 7
  • 36
  • 61
mickey74
  • 71
  • 6

1 Answers1

2

The code you're showing us right now never assigns a value to $_SESSION["login"] so it's never set, therefor $login will never have a value.

And, oh, don't use mysql_.

Community
  • 1
  • 1
Jonast92
  • 4,964
  • 1
  • 18
  • 32
  • @Bulk More strange things have happened, although you're probably right in this case, I removed the unrelated part. – Jonast92 Jan 29 '15 at 14:52
  • Deleted my comment then as it has no context now :) FWIW I think you've got the right answer. – Dan Smith Jan 29 '15 at 14:54