Featured Post Today
print this page
Latest Post

PHP | Login Form | User Will Redirect According To Category

mysql database user category

Login Form Code As Category System:

Sometime you have to redirect user according to his category / position to specific page. So, here this login form code can help you. It is simple code and localhost tested.

 <?php  
  //header('location: index.php');  
  //session_start();  
 function confirm_query($data)  
      {  
           if(!$data)  
                die("Query Failed: " . mysqli_connect_error());       
      }  
 $username = $_POST['username'];  
 $password = $_POST['password'];  
 $host = "localhost";  
 $dbuser = "root";  
 $dbpass = "";  
 $db = "estate";  
      $con = mysqli_connect($host, $dbuser); //Connection with server  
      confirm_query($con);  
      $connection = mysqli_select_db($con, $db); //Database is connected here  
      confirm_query($connection);  
 if(isset($_POST['submit']))  
 {  
      $query = "SELECT * FROM users where username = '{$username}' and password = '{$password}';";  
      $all_users = mysqli_query($con, $query);  
      if(!$all_users)  
           echo 'user pass query not working;' . mysqli_connect_error();  
      $user = mysqli_fetch_array($all_users);  
      if(mysqli_num_rows($all_users) != 0)  
      {  
           if($username == $user[username] AND $password == $user[password])  
           {  
                if($user[Category] == "Receptionist")  
                {  
                     $_SESSION['username'] = $username;  
                     header("location: receptionist.html");  
                     exit;  
                }  
                //Example Like uncomment and change.   
                //make sessions and add code start_session(); in all pages start.  
                /*elseif($user[Category] == "Receptionist")  
                {  
                     $_SESSION['username'] = $username;  
                     header("location: receptionist.html");  
                     exit;  
                }*/  
           }  
      }  
 }  
 else  
 {  
      header("location: login.html");  
      exit;  
 }  
 ?>  

2 comments

C++ | How to show output | Lecture 10

How to show output | C Plus Plus

How to show output in C Plus Plus?

Here you will come to know how to show output in C++. Here a special command is used
cout
Pattern :
cout << "It is Samee Articles: Quality Written Codes Blog. It is How to show output article." ;
termination is very important. don't forget it.
thanks.


 /*  
  Name: Show Output.  
  Copyright: SameeArticles.blogspot.com (Quality Written Codes)  
  Author: Samee Ullah Feroz  
  Date: 26/01/14 23:03  
  Description: Here you will learn C++ basic syntax and function  
 */  
 #include <iostream>  
 int main()  
 { //body starts from here  
   using namespace std; //It will call all standard functions of C++ before body  
   cout << "Welcome to Quality Written Codes.";  
   cout << endl; //It is used to break line  
   cout << "\tSupported by Samee Ullah Feroz." << endl; //it is an other method to break line.  
   // "\t" is used to add tab like in PHP language.  
   system("pause"); //It will help to stop this program  
   return 0; // It will end this function.  
 } //body ends here  

0 comments
 
Copyright © 2011-2026. Samee Articles - All Rights Reserved
Proudly powered by Blogger