Skip to content

Commit

Permalink
UPDATED MVC
Browse files Browse the repository at this point in the history
  • Loading branch information
jaypatel31 committed Aug 9, 2020
1 parent f7cddce commit edc6dea
Show file tree
Hide file tree
Showing 33 changed files with 237 additions and 230 deletions.
16 changes: 8 additions & 8 deletions login.php → Controller/login.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
require('tableConst.php');
require('../common/tableConst.php');
require(CONNECT);


Expand All @@ -26,30 +26,30 @@
$sql = "update ".USER." set last_login = NOW() where id=".$id." limit 1";
$result = $conn->query($sql);
if($row['type']==2){
header('Location: Student_profile.php');
header('Location: ../View/Student_profile.php');
}
else if($row['type']==3){
header('Location: faculty_profile.php');
header('Location: ../View/faculty_profile.php');
}
else{
//update will not return count
if($result){

header('Location: dashboard.php');
header('Location: '.DASH.'');

} else {
header('Location: index.php?error=contact your administrator');
header('Location: '.INDEX.'?error=contact your administrator');
}
}

} else {
header('Location: index.php?error=Invalid credentials');
header('Location: '.INDEX.'?error=Invalid credentials');
}
exit;
} else {
header('Location: index.php?error=Invalid credentials');
header('Location: '.INDEX.'.?error=Invalid credentials');
}
} else {
header('Location: index.php?error=Invalid credentials');
header('Location: '.INDEX.'.?error=Invalid credentials');
}
?>
18 changes: 5 additions & 13 deletions process_faculty.php → Controller/process_faculty.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
<?php
require("session.php");
require('tableConst.php');
require('../common/tableConst.php');
require(SESS);

require(FACM);
if(isset($_SESSION['lang'])){
if($_SESSION['lang']=='fr'){
require('lang.php');
}
else{
require('eng.php');
}
}else{
require('eng.php');
}
require(ADMIN);
if($_POST){
$action = $_POST['action'];
$id = $_POST['id'];
Expand All @@ -37,5 +29,5 @@
$result = InactiveFaculty($status, $id);
}
} else {
header('Location: index.php');
header('Location: '.INDEX);
}
19 changes: 5 additions & 14 deletions process_student.php → Controller/process_student.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
<?php
require("session.php");
require('tableConst.php');
require(STUM);
require('../common/tableConst.php');
require(SESS);

if(isset($_SESSION['lang'])){
if($_SESSION['lang']=='fr'){
require('lang.php');
}
else{
require('eng.php');
}
}else{
require('eng.php');
}
require(STUM);
require(ADMIN);

if($_POST){
$action = $_POST['action'];
Expand All @@ -38,5 +29,5 @@
$result = InactiveStudent($status, $id);
}
} else {
header('Location: index.php');
header('Location: '.INDEX);
}
18 changes: 5 additions & 13 deletions process_user.php → Controller/process_user.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
<?php
require("session.php");
require('tableConst.php');
require('../common/tableConst.php');
require(SESS);

require(USM);
if(isset($_SESSION['lang'])){
if($_SESSION['lang']=='fr'){
require('lang.php');
}
else{
require('eng.php');
}
}else{
require('eng.php');
}
require(ADMIN);
if($_POST){
$action = $_POST['action'];
$id = $_POST['id'];
Expand All @@ -36,5 +28,5 @@
$result = InactiveUser($status, $id);
}
} else {
header('Location: index.php');
header('Location: '.INDEX);
}
27 changes: 10 additions & 17 deletions add.php → Model/add.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
<?php require("session.php");?>
<?php
if(isset($_SESSION['lang'])){
if($_SESSION['lang']=='fr'){
require('lang.php');
}
else{
require('eng.php');
}
}else{
require('eng.php');
}
require('../common/tableConst.php');
require(SESS);
?>
<?php
?>
<?php
require('tableConst.php');
require(ADMIN);
require(CONNECT);
require(STUM);
require(FACM);
Expand All @@ -25,7 +18,7 @@
$type = $_POST['type'];
$result =addUser($username,$password,$type);

header('Location: user.php?message='.$nav['User']." ".$message['added']);
header('Location: '.US.'?message='.$nav['User']." ".$message['added']);

} elseif($_GET['type']=="faculty"){
$name= $_POST['name'];
Expand All @@ -45,7 +38,7 @@
$password = $username;
$type=3;
addUser($username,$password,$type);
header('Location: faculty.php?message='.$nav['Faculty']." ".$message['added']);
header('Location: '.FACUL.'?message='.$nav['Faculty']." ".$message['added']);
} else if($_GET['type']=="student"){
$name= $_POST['name'];
$surname= $_POST['surname'];
Expand All @@ -61,7 +54,7 @@
$password = $username;
$type=2;
addUser($username,$password,$type);
header('Location: student.php?message='.$nav['Student']." ".$message['added']);
header('Location: '.STU.'?message='.$nav['Student']." ".$message['added']);
}
}
}
Expand All @@ -74,7 +67,7 @@
<title>Dashboard - Add</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="js/cities.js"></script>
<script src="../js/cities.js"></script>

<?php require(ADMIN); ?>

Expand Down Expand Up @@ -194,7 +187,7 @@

}
else {
header('Location: index.php');
header('Location: '.INDEX);
}
?>

Expand Down
2 changes: 1 addition & 1 deletion faculty_model.php → Model/faculty_model.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
require('tableConst.php');
require('../common/tableConst.php');
require(CONNECT);


Expand Down
2 changes: 1 addition & 1 deletion student_model.php → Model/student_model.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
require('tableConst.php');
require('../common/tableConst.php');
require(CONNECT);

function getAllStudent(){
Expand Down
2 changes: 1 addition & 1 deletion user_model.php → Model/user_model.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
require('tableConst.php');
require('../common/tableConst.php');
require(CONNECT);

function InactiveUser($status,$total){
Expand Down
13 changes: 8 additions & 5 deletions Student_profile.php → View/Student_profile.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php require("session.php");?>
<?php
require('../common/tableConst.php');
require(SESS);
?>
<?php
require('tableConst.php');

require(CONNECT);
?>
<!DOCTYPE html>
Expand Down Expand Up @@ -33,8 +36,8 @@
</head>
<body>

<?php require("navbar_profile.php") ?>
<?php require("sidemenu_profile.php"); ?>
<?php require("../common/navbar_profile.php") ?>
<?php require("../common/sidemenu_profile.php"); ?>

<div class="col-sm-8 text-left">
<p>Your Profile</p>
Expand All @@ -44,7 +47,7 @@
$name = $_SESSION['username'];
}
echo '<div class="card">
<img src="images/img_avatar.png" alt="Avatar" style="width:100%">
<img src="../images/img_avatar.png" alt="Avatar" style="width:100%">
<div class="card_container">
<h4><b>'.$name.'</b></h4>
<p>Architect & Engineer</p>
Expand Down
5 changes: 3 additions & 2 deletions dashboard.php → View/dashboard.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
require("session.php");
require('tableConst.php');
require('../common/tableConst.php');
require(SESS);

require(STUM);
$stmt ="This dashboard will give you infromation about all students and faculty of Arena Animation.";
$totalS="Total Students In System";
Expand Down
27 changes: 10 additions & 17 deletions faculty.php → View/faculty.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php require("session.php");?>
<?php
require('../common/tableConst.php');
require(SESS);?>
<?php
require('tableConst.php');

require(FACM);
$error=false;
if(isset($_GET['IN'])||isset($_GET['Ac'])||isset($_GET['num'])){
Expand All @@ -26,24 +28,15 @@
}
?>
<?php
if(isset($_SESSION['lang'])){
if($_SESSION['lang']=='fr'){
require('lang.php');
}
else{
require('eng.php');
}
}else{
require('eng.php');
}

?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dashboard - Faculty Master</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="student.js"></script>
<script src="../student.js"></script>
<?php require(ADMIN); ?>

<style>
Expand Down Expand Up @@ -183,7 +176,7 @@
<?php } ?>
<div style="float: right;">
<button type="button" class="btn btn-primary" onClick='location.href="faculty.php"'><?php echo $common['View']?></button>
<button type="button" class="btn btn-success" onClick='location.href="add.php?type=faculty"'><?php echo $common['Add']?></button>
<button type="button" class="btn btn-success" onClick='location.href="../Model/add.php?type=faculty"'><?php echo $common['Add']?></button>
</div>

<?php
Expand All @@ -203,7 +196,7 @@
$row = $result->fetch();
if(isset($_GET['action']) && $_GET['action']=="view"){
echo '<div class="card">
<img src="images/img_avatar.png" alt="Avatar" style="width:100%">
<img src="../images/img_avatar.png" alt="Avatar" style="width:100%">
<div class="card_container">
<h4><b>'.$row["name"].' '.$row["surname"].'</b></h4>
<p>Architect & Engineer</p>
Expand All @@ -213,7 +206,7 @@
?>

<div class="col-md-5">
<form action="process_faculty.php" method="post">
<form action="../Controller/process_faculty.php" method="post">
<input type="hidden" name="action" value="<?php echo $_GET['action'];?>"/>
<input type="hidden" name="id" value="<?php echo $_GET['id'];?>"/>
<div class="form-group">
Expand Down Expand Up @@ -424,7 +417,7 @@ function myFunction() {
setTimeout(function(){ x.className = x.className.replace("show", ""); }, 2000);
var queryString = window.location.search;
if(queryString=="")queryString = "?page=1";
setTimeout(function(){ location.href="faculty.php"+queryString }, 2000);
setTimeout(function(){ location.href="faculty.php" }, 2000);
}
myFunction();
function myFunction1() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php require("session.php");?>
<?php
require('../common/tableConst.php');
require(SESS);?>
<?php
require('tableConst.php');

require(CONNECT);
?>
<!DOCTYPE html>
Expand Down Expand Up @@ -33,8 +35,8 @@
</head>
<body>

<?php require('navbar_profile.php') ?>
<?php require("sidemenu_profile.php"); ?>
<?php require('../common/navbar_profile.php') ?>
<?php require("../common/sidemenu_profile.php"); ?>

<div class="col-sm-8 text-left">
<p>Your Profile</p>
Expand All @@ -44,7 +46,7 @@
$name = $_SESSION['username'];
}
echo '<div class="card">
<img src="images/img_avatar.png" alt="Avatar" style="width:100%">
<img src="../images/img_avatar.png" alt="Avatar" style="width:100%">
<div class="card_container">
<h4><b>'.$name.'</b></h4>
<p>Architect & Engineer</p>
Expand Down
Loading

0 comments on commit edc6dea

Please sign in to comment.