php login form multiple table
<blockquote>
  <p>i tried this code but its saying an error of <strong>unknown column STU_Email
  where clause</strong>.
   my login data is in 4 tables.
  so this code is to identify columns and will redirect their profile page.
  its works for any 1 table if change the coding for 1 table.</p>
</blockquote>

<pre><code> &lt;?php
    include'connection.php';

    $username=$_POST['email'];
    $password=md5($_POST['password']);

    $query= mysql_query("SELECT ST_Email, ST_Password FROM tblstaff_login WHERE ST_Email= '$username' AND ST_Password= '$password'");

    $query2=mysql_query("SELECT tutor_Email, tutor_Password FROM tbltutor_login WHERE tutor_Email= '$username' AND tutor_Password= '$password'");

    $query3=mysql_query("SELECT STU_Email, STU_Password FROM tblstudent_login WHERE STU_Email= '$username' AND STU_Password= '$password'");

    $query4=mysql_query("SELECT Admin_Email, Admin_Password FROM tbladministrator_login WHERE STU_Email= '$username' AND STU_Password= '$password'");
    $data= mysql_fetch_assoc($query);

    $data2=mysql_fetch_assoc($query2);

    $data3=mysql_fetch_assoc($query3);

    $data3=mysql_fetch_assoc($query4);


    if (mysql_num_rows($query)){


        session_start();
        $_SESSION['username']= $data['ST_Email'];
        header("Location: staff_profile.php");
        exit;

        }
        else if (mysql_num_rows($query2)){


        session_start();
        $_SESSION['username']= $data2['tutor_Email'];

        header("Location: tutor_profile.php");
        exit;

        }
        else if (mysql_num_rows($query3)){


        session_start();
        $_SESSION['username']= $data3['STU_Email'];
        header("Location: student_profile.php");
        exit;

        }
        else if (mysql_num_rows($query4)){


        session_start();
        $_SESSION['username']= $data4['Admin_Email'];
        header("Location: Admin_profile.php");
        exit;

        }

        die( "Error:". mysql_error());

    ?&gt;
</code></pre>
