Skip to content

Commit

Permalink
dashboard.php made
Browse files Browse the repository at this point in the history
  • Loading branch information
harshita-2003 committed Jul 23, 2023
1 parent 502af73 commit b55a083
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 4 deletions.
26 changes: 26 additions & 0 deletions Admins/dashboard.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
require('inc/essentials.php');
adminlogin();
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Panel-dashboard</title>
<?php require('inc/links.php')?>
</head>
<body class="bg-light">

<div class="container-fluid bg-dark text-light p-3 d-flex align-items-center justify-content-between">
<h3 class="mb-0">ADMIN PANEL</h3>
<a href="logout.php" class="btn btn-light btn-sm">LOG OUT</a>
</div>




<?php require('inc/scripts.php') ?>
</body>
</html>
35 changes: 34 additions & 1 deletion Admins/inc/essentials.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
<style>
.custom-alert{
top:25px;
right:25px;
}
</style>

<?php

function adminlogin(){

session_start();

if(!(isset($_SESSION['adminLogin']) && $_SESSION['adminLogin']==true)){
echo"
<script>
window.location.href='index.php';
</script>;
";
}
session_regenerate_id(true);
}

function redirect($url){
echo"
<script>
window.location.href='$url';
</script>
";
}

function alert($type,$msg){

$bs_class = ($type=="success") ? "alert-success" : "alert-danger";
$bs_class = ($type=="warning") ? "alert-warning" : "alert-danger";

echo <<<alert
<div class="alert alert-warning alert-dismissible fade show custom-alert" role="alert">
<div class="alert $bs_class alert-dismissible fade show custom-alert" role="alert" style="position:fixed;">
<strong class="me-3">$msg</strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
Expand Down
15 changes: 12 additions & 3 deletions Admins/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php
require('inc/essentials.php');
require('inc/db_config.php')
require('inc/db_config.php');

session_start();
if(isset($_SESSION['adminLogin']) && $_SESSION['adminLogin']==true){
redirect('dashboard.php');
}
?>

<!DOCTYPE html>
Expand Down Expand Up @@ -64,10 +69,14 @@
$res = select($query,$values,$datatype);
// print_r($res);
if($res->num_rows==1){
echo"got user";
// echo"got user";
$row = mysqli_fetch_assoc($res);
$_SESSION['adminLogin'] = true;
$_SESSION['adminId'] = $row['sr_no'];
redirect('dashboard.php');
}
else{
alert('error','Login failed - Invalid Credentials');
alert('warning','Login failed - Invalid Credentials');
}
}
?>
Expand Down
8 changes: 8 additions & 0 deletions Admins/logout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
require('inc/essentials.php');

session_start();
session_destroy();

redirect('index.php');
?>

0 comments on commit b55a083

Please sign in to comment.