User Login Level Type In PHP
Submitted by rinvizle on Wednesday, November 23, 2016 - 17:14.
User Login Type System will show you how to create a user login type by choosing a position to login. This system manage by an admin in the dashboard. Each user has handled by the admin and only the admin can create a new account for each positions. This system helps the users to manage and modified their work through this system. And User login type system compose of PHP, Bootsrap, Javascript, Mysql.
Admin.php - And this is for the admin dashboard to manage and create a users.
Logout.php - This script is for creating a session by which users page has been login and automatically logout where the users sign in.
Hope that you learn in this simple tutorial. Don't forget to LIKE & SHARE this website.
Sample Code
Index.php - This script is where the system creates a session by which the username declares and the position to determine and to access the page.- <?php
- include_once 'connect_db.php';
- $username=$_POST['username'];
- $password=$_POST['password'];
- $position=$_POST['position'];
- switch($position){
- case 'Admin':
- $result=mysql_query("SELECT admin_id, username FROM admin WHERE username='$username' AND password='$password'");
- if($row>0){
- $_SESSION['admin_id']=$row[0];
- $_SESSION['username']=$row[1];
- }else{
- $message="<font color=red>Invalid login Try Again</font>";
- }
- break;
- case 'Teacher':
- $result=mysql_query("SELECT teacher_id, first_name,last_name,username FROM teacher WHERE username='$username' AND password='$password'");
- if($row>0){
- $_SESSION['teacher_id']=$row[0];
- $_SESSION['first_name']=$row[1];
- $_SESSION['last_name']=$row[2];
- $_SESSION['username']=$row[3];
- }else{
- $message="<font color=red>Invalid login Try Again</font>";
- }
- break;
- case 'Faculty':
- $result=mysql_query("SELECT faculty_id, first_name,last_name,username FROM faculty WHERE username='$username' AND password='$password'");
- if($row>0){
- $_SESSION['faculty_id']=$row[0];
- $_SESSION['first_name']=$row[1];
- $_SESSION['last_name']=$row[2];
- $_SESSION['username']=$row[3];
- }else{
- $message="<font color=red>Invalid login Try Again</font>";
- }
- break;
- case 'Student':
- $result=mysql_query("SELECT student_id, first_name,last_name,username FROM student WHERE username='$username' AND password='$password'");
- if($row>0){
- $_SESSION['student_id']=$row[0];
- $_SESSION['first_name']=$row[1];
- $_SESSION['last_name']=$row[2];
- $_SESSION['username']=$row[3];
- }else{
- $message="<font color=red>Invalid login Try Again</font>";
- }
- break;
- }}
- ?>
- <?php
- include_once('connect_db.php');
- $id=$_SESSION['admin_id'];
- $user=$_SESSION['username'];
- }else{
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>User Login Type</title>
- <link rel="stylesheet" type="text/css" href="style/mystyle.css">
- <link rel="stylesheet" type="text/css" href="style/bootstrap.min.css">
- <link rel="stylesheet" href="style/style.css" type="text/css" media="screen" />
- <script src="js/function.js" type="text/javascript"></script>
- <style>
- #left_column{
- height: 470px;
- }
- </style>
- </head>
- <body>
- <nav class="navbar navbar-default">
- <div class="container-fluid">
- <div class="navbar-header">
- <a class="navbar-brand" href="#">Admin Dashboard</a>
- </div>
- <ul class="nav navbar-nav">
- <li class="active"><a href="admin.php">Home</a></li>
- <li><a href="admin_teacher.php">Teacher</a></li>
- <li><a href="admin_student.php">Student</a></li>
- <li><a href="admin_faculty.php">Faculty</a></li>
- <li><a href="logout.php">Logout</a></li>
- </ul>
- </div>
- </nav>
- <div id="content">
- <div id="main">
- <div style="margin-left: 180px;">
- <a href="admin.php" class="dashboard-module">
- <img src="images/dashboard.png" width="75" height="75" alt="edit" />
- <span>Dashboard</span>
- </a>
- <a href="admin_teacher.php" class="dashboard-module">
- <img src="images/teacher.png" width="75" height="75" alt="edit" />
- <span>Teacher</span>
- </a>
- <a href="admin_student.php" class="dashboard-module">
- <img src="images/student.png" width="75" height="75" alt="edit" />
- <span>Student</span>
- </a>
- <a href="admin_faculty.php" class="dashboard-module">
- <img src="images/faculty.png" width="75" height="75" alt="edit" />
- <span>Faculty</span>
- </a>
- </div>
- </div>
- </div>
- </body>
- </html>

- <?php
- ?>
Add new comment
- 1285 views