includes/functions.php
//Function checkes if admin does not exist this will create admin.
Function checkes if admin does not exist this will create admin.
Function checkes if admin does not exist this will create admin .
function redirect_user($user_type) { 
		global $db;
		if(isset($_SESSION['user_type']) && $_SESSION['user_type'] == 'admin') { 
				HEADER('LOCATION: dashboard.php');
			} else {
				$query = "SELECT * from user_level WHERE level_name='".$_SESSION['user_type']."'";
					$result = $db->query($query) or die($db->error);
					$num_rows = $result->num_rows;
					if($num_rows > 0) { 
						$row = $result->fetch_array();
						$page = $row['level_page'];
						HEADER('LOCATION:'.$page);
					} else { 
						HEADER('LOCATION: index.php');
					}
			}
	}
function redirect_user ( $ user_type ) { global $ db ; if ( isset ( $ _SESSION [ 'user_type' ] ) && $ _SESSION [ 'user_type' ] == 'admin' ) { HEADER ( 'LOCATION: dashboard.php' ) ; } else { $ query = " SELECT * from user_level WHERE level_name=' " . $ _SESSION [ 'user_type' ] . " ' " ; $ result = $ db -> query ( $ query ) or die ( $ db -> error ) ; $ num_rows = $ result -> num_rows ; if ( $ num_rows > 0 ) { $ row = $ result -> fetch_array ( ) ; $ page = $ row [ 'level_page' ] ; HEADER ( 'LOCATION:' . $ page ) ; } else { HEADER ( 'LOCATION: index.php' ) ; } } }
Function checkes if admin does not exist this will create admin.
Function checkes if admin does not exist this will create admin .
//If you are not admin and not given access user. You will be redirected to index.php