title: Query for login using multiple tables
body: <p>I've been trying to figure out how to pull this off. I've tried join but it results to an error. I could have made it a single table but students and faculty tables have different fields in them so I couldn't really mix them up. Some fields would be blank for some users. I </p>
  
  <p>Here are my tables:
  faculty, students</p>
  
  <p>fields for faculty are:
  username
  password
  lname
  fname
  subject
  department
  accounttype</p>
  
  <p>fields for students are:
  username
  password
  lname
  fname
  grade
  section
  contact
  birthday
  guardian
  guardiancontact
  accounttype</p>
  
  <p>I hope you can give me an idea.</p>
  
  <pre><code>    &lt;?php
  
              $username = $_POST['username'];
              $password = $_POST['password'];
              $pos="";
  
                      $con=mysql_connect("localhost", "john", "Ichthys030313!") or die ("Unable to connect!");
                      mysql_select_db('SoftEng') or die ("Unable to select database!");
                      $sql = mysql_query("SELECT * FROM login WHERE Username = '$username' and Password = '$password'");
                      $count = mysql_num_rows($sql);
                      $row = mysql_fetch_assoc($sql);
                      if($count == 1)
                      {
                              session_start();
                              $_SESSION['userID'] = $row['AccountType'];
                              $pos = $row['AccountType'];
                      }
                              if($pos=="Admin")
                              {
                                      echo "&lt;script type='text/javascript'&gt;
                                      alert ('Welcome, $username')
                                      window.location.href='adminpanel.php';
                                      &lt;/script&gt;";
                              }
                              elseif($pos="Faculty")
                              {
                                      echo "&lt;script type='text/javascript'&gt;
                                      alert('Welcome, $username')
                                      window.location.href='list.php';
                                      &lt;/script&gt;";
                              }
                              elseif($pos="Student")
                              {
                                      echo "&lt;script type='text/javascript'&gt;
                                      alert('Welcome, $username')
                                      window.location.href='editstudent.php';
                                      &lt;script&gt;";
                              }
  
                      else{
                                      echo "&lt;script type='text/javascript'&gt;
                                      alert ('Wrong Username or Password')
                                      window.location.href='index.php';
                                      &lt;/script&gt;";
                          }
  ?&gt;
  </code></pre>
  
  <p>Database Structure:</p>
  
  <p><img src="https://i.stack.imgur.com/5HIR5.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/JrWNl.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/hzQdP.png" alt="enter image description here"></p>