Beruflich Dokumente
Kultur Dokumente
Program Listing
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
</div>
</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);
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'];
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>
</div>
</form>
</div>
</div>
</div>
</div> <!-- /container -->
</html>
header.php
</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
/*!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`
--
--
-- Dumping data for table `user_levels`
--
--
-- 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 */;