Subscribe To Our Newsletter

Sign Up Now To Get SEO and Programming Tips

We Hate Spam! Really, It's terrible and we never do it.

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;  
 }  
 ?>  

Share this article :

+ comments + 2 comments

June 7, 2014 at 4:12 PM

Thanks for giving important information to training seekers,Keep posting useful information..

PHP Training Institutes in Chennai

November 28, 2014 at 2:19 PM

Its best example for creating signup form using php

by
Sri Priya( Web Designing Training in Chennai )

Post a Comment

Give your reviews about this blog. Leave your comments. what do you think about this post?

Comments Description is given below:
1) I love to read comments, but do not spam.
2) Like this blog and also tweet its posts.
3) You can use some xHTML tags.
4) All Comments are Do Follow, Please try to use blog professionally.
5) Mention Your Name below the comment.
6) You can also suggest for improvement.
7) Do not forget to subscribe FusionMarketPro.online blog.

---------------------------------------
Thanks for visiting FusionMarketPro.Online.
==========================================
Join Sami Jeweller and Shop online jewelry for your someone special.
==========================================
Best Regards

 
Copyright © 2013-2016. Samee Articles - All Rights Reserved
Proudly powered by Blogger