Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is a mistake in your query:</p> <pre><code>//$result2 = $mysqli_query($con,"SELECT occupation FROM tbladmin WHERE admin_usr_name ='$username'" == 'student'); //$row == mysqli_fetch_array($result) </code></pre> <p>you can't use = to something == to something else.</p> <p>here is the entire code as i think should work</p> <pre><code>&lt;?php session_start(); //*********Server Information to establish a connection ****** $host = 'localhost'; $user = 'kurtfarrugia'; $dbpassword = '1234'; $database = 'kurt_farrugia'; //Open connection $mysqli = new mysqli($host, $user, $dbpassword, $database); if (mysqli_connect_errno()) { printf("Connection failed: %s\n", mysqli_connect_error()); exit(); } //***************End Connection Establishment*************************************** //*******Form Information******** $userName = mysql_real_escape_string($_POST['username']); //User Name sent from Form $userPassword = mysql_real_escape_string($_POST['password']); // Password sent from Form // $rememberMe = strip_tags($_POST['rememberMe']); setcookie("username", $_POST['username']); //*********retrieving data from Database********** $result2 = $mysqli-&gt;query("SELECT * FROM `tbladmin` WHERE `admin_usr_name` = '".$userName."' and `admin_pwd` = '".$userPassword."'"); if($row = $result2-&gt;fetch_assoc()) { if($row['occupation'] == 'student') { // redirect logged student } else if($row['occupation'] == 'lecturer') { // redirect logged lecturer } } else { //username doesn't exist redirect to fail page } //**********it ensures that the script does not continue unless the username varaible is not null and not empty if (!empty($_POST['username'])) { $username = mysql_real_escape_string(strip_tags(trim($_POST['username']))); } else { //die('Hey turd, go back and fill in your username!'); header( "Location: login_fail2.php" ); die; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload