PHP separated login for admin users

240
March 05, 2017, at 2:56 PM

someone helped on how to implement my login using different table but now i want different user in the specific table for example the stock manager has a separate page and separate page for the admin. heres my code hope you understand just tell me if need to re edit for some reason.

            $email = $_POST['email'];
            $password = $_POST['password'];
            $tableName = "";
            function login($tableName){
               global $connect, $email, $password;
               $query = "SELECT * FROM ". $tableName ." WHERE email=? AND password=? LIMIT 1";
               $statement = mysqli_prepare($connect, $query); 
               mysqli_stmt_bind_param($statement, "ss", $email, $password);
               mysqli_stmt_execute($statement);
               mysqli_stmt_store_result($statement);
               $count = mysqli_stmt_num_rows($statement);
               mysqli_stmt_close($statement); 
               $row = mysqli_fetch_array($statement);
               return ($count == 1);
             }
             if(login('tbl_users')){
                  $_SESSION['user'] = $row['email'];
                  $_SESSION['position'] = $row['position'];
                  header('Location:../index.html');
               } else if (login('tbl_gramusers')){
                   if($row['position']=="Stocks Controller")
                   {
                       header('Location:../stocks_index.html');
                   }
                  header('Location:../admin.html');
               } else {
                 echo 'Wrong Username or password!';
               }
READ ALSO
PHP Unable to retrieve data using GET Method

PHP Unable to retrieve data using GET Method

I am new to PHP, today I was trying to implement a get methodI am trying to get data based on a token that already exists but, unable to retrive data

248
while loop output increasing digits and break

while loop output increasing digits and break

i have here a problem that needs to output the same pattern as below

171
How to avoid creating function/method with many parameters?

How to avoid creating function/method with many parameters?

Supposed I have method of repository class like this to create post:

227