Hi everyone!
As u can see by my username, I'm a newbie in PHP.
Now to the question:
I have made a site that extracts data (in my case movies) that logs in a user and shows all data that the user has entered as a table. I've written some titles in MySQL manually to see if it works and it did. The problem starts when I try to add a new title. The following message appears....
Notice: Undefined index: user in C:\wamp\www\login.php on line 9

Notice: Undefined index: pass in C:\wamp\www\login.php on line 10

I'll attach my 2 files here for anyone who's intersted to see.
Please help!
Thanks in advance!

Attachments
<html>
<body style="background-color:powderblue;">
     <head><title> 90s nostalgia </title> </head>
        <h1 style="text-align:center">"90's club "</h1> </br></br>
  <?php
        include("c:\wamp\www\conf.php");
  $login= $_POST['user'];
   $password= $_POST['pass'];
       if (isset($_POST['user'] ,$_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('username', $login, mktime()+300, '/');
         ?>
            <p style="text-align:center;font-size:30px"> Welcome  <?php echo $login ?>!  </p>
         <form action="<?php echo $_SERVER['PHP_SELF']; ?>"
               method="POST"   style="text-align:center"  >
               Give your proposal here:
               </br> </br> </br>
               Title:<input type="text" name="title">
                     <input type="submit" value="add"  style=" height:35;width:70">

            <form  action="<?php echo $_SERVER['PHP_SELF']; ?>"
               method="POST"   style="text-align:center"  >
            Category:<input type="text" name="category">
                     <input type="submit" value="add"  style=" height:35;width:70">

               <form  action="<?php echo $_SERVER['PHP_SELF']; ?>"
               method="POST"   style="text-align:center"  >
                  Year:<input type="text" name="year">
                     <input type="submit" value="add"  style=" height:35;width:70">
          <?php

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

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


           <p style"text-align:center;font-size:23">Your titles:</p>

           
            <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>';
                } 
                 isset($_POST['title'])?$title = $_POST['title']:$title = "";
                   isset($_POST['category'])?$category= $_POST['category']:$category = "";
                    isset($_POST['year'])?$year = $_POST['year']:$year = "";


                 while ($title )
                {
                $query3= "insert into movie (title,user) values ('$title','$login')";
             mysql_query($query3);
                }
           ?>

        </table> </div>
        
        <?php
             }
              else
              {
                echo "Invalid username!" ;

              }
       }
               ?>

</body>
</html>
<html>
<body style="background-color:powderblue;">
<head>
      <title> 90's nostalgia </title>
</head>
<h1 style="text-align:center"> Club 90's </h1>

    <form name="input" action="list.php" method="post" style="text-align:center">
          search movies here</br>
          <input style=text name="search" size="40">
          </br>
          <input type="submit" value="search" style="height:35;width:70">
    </form>

      


 <p style="text-align:right" > User login </br></p>

   <form name="login" action="login.php" style="text-align:right" method="POST">
          Username:
          <input style="text" name="user"  >
          </br>
          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          Password:
          <input type="password" name="pass"  >
          </br>

          <input type="submit" value="login" style=" height:35;width:70"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    </form>


       <p style="text-align:center;font-size:23px"> We are a community for all 90's freeks. </br>
       Every second week, we meet at the university </br>
       to watch some movies of the 90's' </br>
       that our members propose. </br>
       Join us! Become a member!</br>   </br></br>
       As a member you can add movies </br>
       or delete or even change title info. </p>

</body>
</html>

are you running a server on your local machine correct me if im wrong but shouldn't your include be something more like this

include "somefile.php";

or like this

include "../somefolder/somefile.php";

move

$login= $_POST['user'];
   $password= $_POST['pass'];

under the if statement

if (isset($_POST['user'] ,$_POST['pass']))
       {

in login.php

are you running a server on your local machine correct me if im wrong but shouldn't your include be something more like this

include "somefile.php";

or like this

include "../somefolder/somefile.php";

Hi! Sorry for replying so late. I thought that this thread was deleted. Yes, I'm running on localhost. I've changed to this "../somefolder/somefile.php"; format, but it still doesn't work.
Thanks anyway.

move

$login= $_POST['user'];
   $password= $_POST['pass'];

under the if statement

if (isset($_POST['user'] ,$_POST['pass']))
       {

in login.php

Thanks for your reply! I tried this and it removed the error/warnings I was receiving, but it doesn't insert the title. I checked PHPMyAdmin, but the title I submitted wasn't there. You can see the login page, but without the original table.

or at top of the script use:

error_reporting(E_ALL ^ E_NOTICE);

Hi! Thanks for your help.
I tried this also and it removed the warnings. Unfortunately, I still got issues with inserting a title...

Thanks to all you guys for your help!
The undefined index problem is gone. I still got issues with inserting a title but that's a different topic. So I'll make a different thread instead.

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