Skip to content

Commit

Permalink
CRUD Application implimented.
Browse files Browse the repository at this point in the history
-SQL commands are updated in Database Design folder.(Alpha1)
  • Loading branch information
zamans78 committed Feb 2, 2021
1 parent 81a5f17 commit 283e8b9
Show file tree
Hide file tree
Showing 11 changed files with 679 additions and 134 deletions.
30 changes: 27 additions & 3 deletions assets/Database_Design/SQL Commands/3.Alpha1.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
CREATE TABLE Admin (
Admin_ID INTEGER NOT NULL PRIMARY KEY,
Password VARCHAR(255)
)ENGINE = InnoDB;

CREATE TABLE Contact_Us (
Name VARCHAR(100),
Email VARCHAR(255),
Query TEXT,
Image VARCHAR(255),
Query_Datetime TIMESTAMP,
INDEX (Name),
INDEX (Email)
)ENGINE = InnoDB;

CREATE TABLE Reset_Password (
ID INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
Email VARCHAR(255),
Code VARCHAR(255),
Requested_Datetime TIMESTAMP,

INDEX (Code),
INDEX (Email)
)ENGINE = InnoDB;

CREATE TABLE Teacher (
Teacher_ID INTEGER NOT NULL PRIMARY KEY,
Expand Down Expand Up @@ -37,9 +60,10 @@ CREATE TABLE Question(


CREATE TABLE Posted_Question (
Question_Description_ID INTEGER NOT NULL PRIMARY KEY,
Question_ID INTEGER NOT NULL PRIMARY KEY,
Question_Description_ID INTEGER NOT NULL,
Question_ID INTEGER NOT NULL,
Post_Datetime TIMESTAMP,
PRIMARY KEY (Question_Description_ID, Question_ID),

CONSTRAINT FOREIGN KEY (Question_Description_ID)
REFERENCES Question (Question_Description_ID)
Expand Down Expand Up @@ -94,4 +118,4 @@ CREATE TABLE Answer (
CONSTRAINT FOREIGN KEY (Student_ID)
REFERENCES Student_Answer (Student_ID)
ON DELETE NO ACTION ON UPDATE NO ACTION
)ENGINE = InnoDB;
)ENGINE = InnoDB;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions assets/inc/validation_helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

function validationHelper()
{
if (strlen($_POST['Course_Code']) < 1 || strlen($_POST['Course_Name']) < 1 || strlen($_POST['Title']) < 1 ||
strlen($_POST['Batch']) < 1 || strlen($_POST['Section']) < 1) {
$_SESSION['status'] = "All fields are required";
return false;
}

for ($i = 1; $i <= 9; $i++) {

if (!isset($_POST['Question' . $i])) {
continue;
}

$Question = htmlentities($_POST['Question' . $i]);

if (strlen($Question) < 1) {
$_SESSION['status'] = "All fields are required";
return false;
}
}
return true;
}
59 changes: 59 additions & 0 deletions question_delete.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

session_start();
require_once "assets/connect/pdo.php";

if (isset($_POST['Delete']) && isset($_POST['Question_Description_ID'])) {
echo 23132;
$sql = "DELETE FROM question_description WHERE Question_Description_ID = :zip";
$stmt = $pdo->prepare($sql);
$stmt->execute(array(':zip' => $_POST['Question_Description_ID']));
$_SESSION['success'] = 'Record deleted';
header('Location: teacher_dashboard.php');
return;
}

// Guardian: Make sure that user_id is present
if (!isset($_GET['Question_Description_ID'])) {
$_SESSION['error'] = "Missing user_id";
header('Location: teacher_dashboard.php');
return;
}

$stmt = $pdo->prepare("SELECT Course_Code, Course_Name FROM question_description where Question_Description_ID = :xyz");
$stmt->execute(array(":xyz" => $_GET['Question_Description_ID']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if ($row === false) {
$_SESSION['error'] = 'Bad value for Question Description ID';
header('Location: teacher_dashboard.php');
return;
}
?>

<!DOCTYPE html>
<html>
<head>
<?php
require_once 'assets/connect/head.php';
?>
</head>
<header>
<nav class="navbar navbar-expand-lg navbar-light sticky-top">
<a class="navbar-brand" href="#">LU EXAM HIVE</a>
<button type="button" class="btn btn-sm btn-dark rounded-0 ml-3">
<a href="teacher_dashboard.php" class="text-white text-decoration-none">Back</a>
</nav>

</header>
<body>
<div class="container">
<p>Course Code: <?php echo ($row['Course_Code']); ?></p>
<p>Course Name: <?php echo ($row['Course_Name']); ?></p>
<form method="post"><input type="hidden" name="Question_Description_ID" value="<?php echo $_GET['Question_Description_ID'] ?>">
<input type="submit" name="Delete" value="Delete">
</form>
</div>
<?php
require_once 'assets/connect/footer.php';
?>
</body>
Loading

0 comments on commit 283e8b9

Please sign in to comment.