Hi!
I've made a members.php page that is supposed to show all the entries done by the user, in other words, the title, category and year of a movie. After login in the user clicks on a link (href="members.php") and is redirected to members.php.
My problem is that the table is empty, even though there are a couple of titles in the database. Whats wrong with my code?
I appreciate any help!
I'll add my login.php just in case.
Thanks in advance!

Attachments
<html>
<html>
<head><title> 90s nostalgia </title> </head>
<body style="background-color:powderblue;">
<h1 style="text-align:center">club 90s </h1> </br></br>
  <?php
        include("c:\wamp\www\conf.php");

      if (isset($_POST['user'] ,$_POST['pass']))
       {
   $login= $_POST['user'];
   $password= $_POST['pass'];

        $connection=@mysql_connect($host, $user, $pass)or die("Unable to connect!");
       mysql_select_db($db, $connection) or die ('Unable to select database!');

       $query="select id from user where username='$login' and password='$password'";
            $result=mysql_query($query);
            
            $num=mysql_num_rows($result);

            if($num>0)
                {
        setcookie('cookiename', $login, mktime()+3600, '/');
       $name= $_COOKIE["cookiename"];
         ?>
            <p style="text-align:center;font-size:30px"> Welcome  <?php echo $name ?>!</p>

            <p><a href="members.php">To main page</a></p>
        <?php
                }
              else
              {
                echo "Invalid username!" ;

              }
     }
               ?>

</body>
</html>
<html>
<body style="background-color:powderblue;">

          <?php
          include("c:\wamp\www\login.php");

                  $name2= $_COOKIE["cookiename"];

                  $connection=@mysql_connect($host, $user, $pass)or die("Unable to connect!");
                  mysql_select_db($db, $connection) or die ('Unable to select database!');

                $query2= "select title, category, year from movie where user=' $name2'";
                $result2=mysql_query($query2);

          ?>
           </br> </br> </br> </br> </br>


           <p style"text-align:center;font-size:23"><a name="rubrik">Your proposal:</a></p>
              <font size="2"><a href="add.php" >add title</a></font>
           
            <div style="text-align:center">
           <table width="800" border="1">
                   <th>Title</th><th>Category</th><th>Year</th>
           <?php



                while ($row = mysql_fetch_assoc($result2))
               {
      echo '<tr>'.
           '<td>'.$row['title'].'</td>'.'<td>'.$row['category'].'</td>'.'<td>'.$row['year'].'</td>'.
           '</tr>';
                } 


           ?>

        </table> </div>
</body>
 </html>

I only look at your sql query in members.php $query2= "select title, category, year from movie where user=' $name2'"; Is the extra space after the first quote is there on purpose?
Assuming $name2 = 'userName'
you are comparing user attribute in database with ' userName' instead of 'userName'.
also check that $name2 gets the proper value.

I only look at your sql query in members.php $query2= "select title, category, year from movie where user=' $name2'"; Is the extra space after the first quote is there on purpose?
Assuming $name2 = 'userName'
you are comparing user attribute in database with ' userName' instead of 'userName'.
also check that $name2 gets the proper value.

Hi liranoz!
Thanks for your help! Now it works!
It was the extra space in '$name2' that was the problem.

This question has already been answered. Start a new discussion instead.