Here is a sample program that I wrote using PHP and MySQL that allows the user to login in different user levels or rules in the system. The code is very compatible with PHP 7 database connections and queries. I hope you will find my work useful. Thank you very much.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
/* Written By: Mr. Jake Rodriguez Pomperada, MAED-IT */
/* Tools : PHP / MySQL */
/* May 4, 2017 Thursday */
/* jakerpomperada@yahoo.com and jakerpomperada@gmail.com */
connect.php
<?php
$username="root";
$password="";
$hostname = "localhost";
//connection string with database
$dbhandle = mysqli_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "";
// connect with database
$selected = mysqli_select_db($dbhandle, "levels")
or die("Could not select examples");
?>
index.php
<?php include("header.php"); ?>
<body>
<div class="container">
<div id="loginbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
<div class="panel panel-info" >
<div class="panel-heading">
<div class="panel-title">Login Security Page</div>
</div>
<div style="padding-top:30px" class="panel-body" >
<div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>
<form action="login_action.php" method="post">
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="login-username" type="text" class="form-control" name="username" value="" placeholder="username">
</div>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input id="login-password" type="password" class="form-control" name="password" placeholder="password">
</div>
<div style="margin-top:10px" class="form-group">
<!-- Button -->
<div class="col-sm-12 controls">
<input type="button" class="btn btn-success pull-right" style='margin-left:25px'
value="Register" title="Click here to register to the system." onclick="location.href = 'register.php';">
<button type="submit" class="btn btn-success pull-right" title="Click here to Login in the system." >
<span class="glyphicon glyphicon-check"></span> Login</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div> <!-- /container -->
<script src="js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>
login_action.php
<?php
include("connect.php");
$tbl_name="user_levels";
$username=$_POST['username'];
$password=$_POST['password'];
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysqli_real_escape_string($dbhandle,$username);
$password = mysqli_real_escape_string($dbhandle,$password);
$result = mysqli_query($dbhandle, "SELECT * FROM $tbl_name WHERE username='$username' AND password='$password'");
if(mysqli_num_rows($result) != 1){
echo "<script>alert(' Wrong Username or Password Access Denied !!! Try Again');
window.location='index.php';
</script>";
}else{
$row = mysqli_fetch_assoc($result);
if($row['userlevel'] == 1){
header('location: admin.php');
}else if($row['userlevel'] == 2 ){
header("Location: faculty.php");
}else if($row['userlevel'] == 3 ){
header("Location: student.php");
}
else if($row['userlevel'] == 4 ){
header("Location: staff.php");
}
else{
echo "<script>alert('Wrong Username or Password Access Denied !!! Try Again');
window.location='index.php';
</script>";
}
}
?>
insert.php
<?php
include("connect.php");
$tbl_name="user_levels";
$username=$_POST['username'];
$password=$_POST['password'];
$user_level = $_POST['user_level'];
$result = mysqli_query($dbhandle, "INSERT INTO $tbl_name (username,password,userlevel) VALUES ('$username','$password','$user_level')");
if($result===TRUE)
{
echo "<script>alert('User Account has been saved in the database.');
window.location='index.php';
</script>";
}
else
{
echo"The query did not run";
}
mysqli_close($result);
?>
register.php
<html>
<?php include("header.php"); ?>
<body>
<div class="container">
<div id="loginbox" style="margin-top:50px;" class="mainbox col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
<div class="panel panel-info" >
<div class="panel-heading">
<div class="panel-title">Registration Page</div>
</div>
<div style="padding-top:30px" class="panel-body" >
<div style="display:none" id="login-alert" class="alert alert-danger col-sm-12"></div>
<form action="insert.php" method="post">
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="login-username" type="text" class="form-control" name="username" value="" placeholder="username" autofocus required>
</div>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input id="login-password" type="password" class="form-control" name="password" placeholder="password" required>
</div>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="login-user_level" type="text" class="form-control" name="user_level" placeholder="user level" required>
</div>
<div style="margin-top:10px" class="form-group">
<!-- Button -->
<div class="col-sm-12 controls">
<input type="button" class="btn btn-success pull-right" style='margin-left:25px' value="Cancel"
title="Click to return to main page." onclick="location.href = 'index.php';">
<button type="submit" class="btn btn-success pull-right" title="Click here to save the records in the database." >
<span class="glyphicon glyphicon-check"></span> Ok</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div> <!-- /container -->
</html>
header.php
<?php include("connect.php"); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>User - Levels</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="signin.css" rel="stylesheet">
<script src="js/ie-emulation-modes-warning.js"></script>
</head>
admin.php
<html>
<head>
<title> Administrator Page </title>
<head>
<style>
body {
font-family:arial;
background-color : lightblue;
color:red;
};
</style>
<body><br>
<h1 align="center">
Welcome To Administrator Page
</h1>
</body>
</html>
faculty.php
<html>
<head>
<title> Administrator Page </title>
<head>
<style>
body {
font-family:arial;
background-color : lightblue;
color:red;
};
</style>
<body><br>
<h1 align="center">
Welcome To Administrator Page
</h1>
</body>
</html>
student.php
<html>
<head>
<title> Student Page </title>
<head>
<style>
body {
font-family:arial;
background-color : yellow;
color:blue;
};
</style>
<body><br>
<h1 align="center">
Welcome To Student Page
</h1>
</body>
</html>
staff.php
<html>
<head>
<title> Staff Page </title>
<head>
<style>
body {
font-family:arial;
background-color : pink;
color:yellow;
};
</style>
<body><br>
<h1 align="center">
Welcome To Staff Page
</h1>
</body>
</html>
user_levels.sql
-- phpMyAdmin SQL Dump
-- version 4.6.5.2
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: May 03, 2017 at 01:52 PM
-- Server version: 10.1.21-MariaDB
-- PHP Version: 7.0.15
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `levels`
--
-- --------------------------------------------------------
--
-- Table structure for table `user_levels`
--
CREATE TABLE `user_levels` (
`id` int(11) NOT NULL,
`username` varchar(20) NOT NULL,
`password` varchar(20) NOT NULL,
`userlevel` varchar(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `user_levels`
--
INSERT INTO `user_levels` (`id`, `username`, `password`, `userlevel`) VALUES
(1, 'user1', 'user1', '1'),
(2, 'user2', 'user2', '2'),
(3, 'user3', 'user3', '3'),
(4, 'user4', 'user4', '4'),
(5, 'admin', 'admin', '1'),
(6, 'a', 'a', '1'),
(8, 'adam', 'adam', '2'),
(9, 'jake', 'jake', '3'),
(10, 'jacob', 'jacob', '2'),
(11, 'mark', 'mark', '4'),
(12, 'jose', 'jose', '2'),
(13, 'mario', 'mario', '2');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `user_levels`
--
ALTER TABLE `user_levels`
ADD PRIMARY KEY (`id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `user_levels`
--
ALTER TABLE `user_levels`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=14;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
thank you sir !
ReplyDeleteProgramming Source Codes And Computer Programming Tutorials: Multi Level User Login And Registration System In Php And Mysql >>>>> Download Now
ReplyDelete>>>>> Download Full
Programming Source Codes And Computer Programming Tutorials: Multi Level User Login And Registration System In Php And Mysql >>>>> Download LINK
>>>>> Download Now
Programming Source Codes And Computer Programming Tutorials: Multi Level User Login And Registration System In Php And Mysql >>>>> Download Full
>>>>> Download LINK
yozgat
ReplyDeletesivas
bayburt
van
uşak
PWNUA
Bolu Lojistik
ReplyDeleteMardin Lojistik
Kocaeli Lojistik
Diyarbakır Lojistik
İstanbul Lojistik
RHEL14
Çorum Lojistik
ReplyDeleteKaraman Lojistik
Gümüşhane Lojistik
Denizli Lojistik
Artvin Lojistik
Q0G6
sivas evden eve nakliyat
ReplyDeleteerzurum evden eve nakliyat
bitlis evden eve nakliyat
mardin evden eve nakliyat
rize evden eve nakliyat
CDFİDK
D5E61
ReplyDeleteSilivri Çatı Ustası
Isparta Evden Eve Nakliyat
Ankara Asansör Tamiri
Kütahya Evden Eve Nakliyat
Maraş Evden Eve Nakliyat
EDDCB
ReplyDeleteÇerkezköy Çatı Ustası
Denizli Şehirler Arası Nakliyat
Siirt Evden Eve Nakliyat
Mersin Şehirler Arası Nakliyat
Bayburt Parça Eşya Taşıma
Ordu Parça Eşya Taşıma
Zonguldak Parça Eşya Taşıma
Nevşehir Şehirler Arası Nakliyat
Mercatox Güvenilir mi
B5C2E
ReplyDeleteBitfinex Güvenilir mi
Altındağ Fayans Ustası
Hakkari Lojistik
İstanbul Lojistik
Antalya Lojistik
Antalya Parça Eşya Taşıma
Siirt Evden Eve Nakliyat
Kars Evden Eve Nakliyat
Samsun Şehir İçi Nakliyat
A0458
ReplyDeleteAltındağ Fayans Ustası
Artvin Şehir İçi Nakliyat
Adana Şehir İçi Nakliyat
Muğla Parça Eşya Taşıma
Rize Şehir İçi Nakliyat
Denizli Parça Eşya Taşıma
Rize Lojistik
Siirt Şehirler Arası Nakliyat
Hatay Lojistik
E0A5E
ReplyDeleteMuğla Lojistik
Ünye Koltuk Kaplama
Edirne Şehirler Arası Nakliyat
Çerkezköy Oto Elektrik
Siirt Parça Eşya Taşıma
Şırnak Şehir İçi Nakliyat
Ordu Şehirler Arası Nakliyat
Giresun Şehir İçi Nakliyat
Kars Lojistik
46096
ReplyDeleteorder sustanon
Coin Nedir
fat burner for sale
Sivas Evden Eve Nakliyat
buy testosterone enanthate
buy testosterone propionat
Tekirdağ Evden Eve Nakliyat
trenbolone enanthate
testosterone enanthate
E1144
ReplyDeleteÇerkezköy Korkuluk
Chat Gpt Coin Hangi Borsada
Mardin Evden Eve Nakliyat
Ordu Parça Eşya Taşıma
Zonguldak Parça Eşya Taşıma
Çanakkale Lojistik
Sinop Evden Eve Nakliyat
Zonguldak Şehir İçi Nakliyat
Kilis Şehir İçi Nakliyat
AFB55
ReplyDeleteKırşehir Şehirler Arası Nakliyat
Altındağ Parke Ustası
Gümüşhane Şehirler Arası Nakliyat
Tekirdağ Parça Eşya Taşıma
Hakkari Evden Eve Nakliyat
Ağrı Lojistik
Ünye Televizyon Tamircisi
Gate io Güvenilir mi
Bingöl Şehir İçi Nakliyat
8CE1E
ReplyDeleteHotbit Güvenilir mi
Adıyaman Şehirler Arası Nakliyat
Aydın Şehir İçi Nakliyat
Kastamonu Evden Eve Nakliyat
Muş Şehirler Arası Nakliyat
Afyon Şehir İçi Nakliyat
Telcoin Coin Hangi Borsada
Ardahan Evden Eve Nakliyat
Poloniex Güvenilir mi
425A2
ReplyDelete%20 referans kodu
2B49F
ReplyDeletebartın canlı sohbet sitesi
Kayseri Sohbet Sitesi
sohbet uygulamaları
canli sohbet
yalova telefonda kızlarla sohbet
düzce sohbet sitesi
kayseri mobil sohbet bedava
Antep Chat Sohbet
çorum en iyi sesli sohbet uygulamaları
041FB
ReplyDeleteSinop Mobil Sohbet Siteleri
sohbet sitesi
sakarya mobil sohbet
sesli görüntülü sohbet
kastamonu ücretsiz sohbet siteleri
erzurum parasız sohbet siteleri
Aydın Bedava Sohbet Chat Odaları
Mardin Rastgele Sohbet Uygulaması
hakkari bedava sohbet
49CA8
ReplyDeleterize ücretsiz sohbet uygulaması
en iyi ücretsiz sohbet siteleri
Bolu Rastgele Sohbet Uygulaması
kocaeli bedava görüntülü sohbet sitesi
Kastamonu Bedava Sohbet Siteleri
Trabzon En İyi Görüntülü Sohbet Uygulamaları
görüntülü sohbet uygulama
en iyi ücretsiz sohbet siteleri
kastamonu rastgele sohbet siteleri
ACF96
ReplyDeleteTelegram Abone Satın Al
Telegram Görüntüleme Satın Al
Mexc Borsası Kimin
Arg Coin Hangi Borsada
Spotify Dinlenme Hilesi
Kwai Beğeni Satın Al
Okex Borsası Güvenilir mi
Periscope Beğeni Satın Al
Bitcoin Kazanma
4DC76
ReplyDeleteSoundcloud Dinlenme Hilesi
Coin Kazma
Soundcloud Dinlenme Satın Al
Bitcoin Kazma Siteleri
Binance Referans Kodu
Tumblr Beğeni Hilesi
Bitranium Coin Hangi Borsada
Hexa Coin Hangi Borsada
Coin Çıkarma
BACE0
ReplyDeleteAkkışla
Tavas
Eruh
Erdemli
İzmir Kızları
Kastamonu
Merzifon
Çanakkale
Iğdır