+
+
+
diff --git a/custom.css b/custom.css
index f2da08a8..862d1f50 100644
--- a/custom.css
+++ b/custom.css
@@ -145,4 +145,29 @@ body {
.form-inline .form-group {
display: inline-block;
margin-right: 10px;
- }
\ No newline at end of file
+ }
+
+ /* Main Navigation Styles */
+#main-nav {
+ background-color: #333; /* Dark background */
+ color: #fff; /* White text */
+ padding: 1rem; /* Padding around the nav */
+ text-align: center; /* Center the navigation links */
+}
+
+#main-nav a {
+ color: #ddd; /* Light grey text for links */
+ text-decoration: none; /* Remove underline from links */
+ margin: 0 10px; /* Space out the links */
+ font-weight: bold; /* Make the link text bold */
+ transition: color 0.3s ease-in-out; /* Smooth transition for hover effect */
+}
+
+#main-nav a:hover {
+ color: #4CAF50; /* Change link color on hover */
+}
+
+/* Add a custom style for the current/active page link if needed */
+#main-nav a.active {
+ color: #ff6347; /* Highlight color for the active page */
+}
diff --git a/students.php b/students.php
index c2d8fcb5..e2ef9ab4 100644
--- a/students.php
+++ b/students.php
@@ -4,6 +4,10 @@
include("_includes/dbconnect.inc");
include("_includes/functions.inc");
+
+echo template("templates/partials/header.php");
+echo template("templates/partials/nav.php");
+
echo "\n";
echo "\n";
echo "\n";
@@ -12,54 +16,57 @@
echo " Student Records\n";
echo "\n";
echo "\n";
-echo "
Student Records
\n";
-echo "
\n";
-echo "
\n";
-echo "
Select
\n";
-echo "
Student ID
\n";
-echo "
Password
\n"; // Consider security implications
-echo "
Date of Birth
\n";
-echo "
First Name
\n";
-echo "
Last Name
\n";
-echo "
House
\n";
-echo "
Town
\n";
-echo "
County
\n";
-echo "
Country
\n";
-echo "
Postcode
\n";
-echo "
Image
\n"; // Image column header
-echo "
\n";
+echo "
Student Records
\n";
+// Start of form
+echo "
\n";
+echo "\n";
+echo "\n"; // End of form
echo "\n";
echo "\n";
From fd03abcbface8da761131865d65a21403f40f5af Mon Sep 17 00:00:00 2001
From: Richard Ochei <162317835+OxheiCodes@users.noreply.github.com>
Date: Wed, 27 Mar 2024 00:31:21 +0000
Subject: [PATCH 05/13] Task 7 Injections Completed
---
process_addstudent.php | 52 ++++++++++++++++++++++--------------------
1 file changed, 27 insertions(+), 25 deletions(-)
diff --git a/process_addstudent.php b/process_addstudent.php
index 3ebbd0e1..dcbeb759 100644
--- a/process_addstudent.php
+++ b/process_addstudent.php
@@ -4,35 +4,37 @@
include("_includes/dbconnect.inc");
include("_includes/functions.inc");
-// Handle file upload
-$imagePath = '';
-if (isset($_FILES['image']) && $_FILES['image']['error'] == 0) {
- // Validate file type (for example, only jpg and png)
- $allowedTypes = ['image/jpeg' => 'jpg', 'image/png' => 'png'];
- if (array_key_exists($_FILES['image']['type'], $allowedTypes)) {
- // Create a unique file name and save the file
- $fileExtension = $allowedTypes[$_FILES['image']['type']];
- $fileName = uniqid('img_', true) . '.' . $fileExtension;
- $imagePath = 'uploads/' . $fileName; // Ensure the 'uploads' directory exists and is writable
- move_uploaded_file($_FILES['image']['tmp_name'], $imagePath);
+// Check if the form was submitted
+if ($_SERVER["REQUEST_METHOD"] == "POST") {
+ // Fetch and sanitize input data
+ $studentid = $conn->real_escape_string($_POST['studentid']);
+ $password = $conn->real_escape_string($_POST['password']);
+ // Assume password will be hashed before storage
+ $hashedPassword = password_hash($password, PASSWORD_DEFAULT);
+ $dob = $conn->real_escape_string($_POST['dob']);
+ $firstname = $conn->real_escape_string($_POST['firstname']);
+ $lastname = $conn->real_escape_string($_POST['lastname']);
+ $house = $conn->real_escape_string($_POST['house']);
+ $town = $conn->real_escape_string($_POST['town']);
+ $county = $conn->real_escape_string($_POST['county']);
+ $country = $conn->real_escape_string($_POST['country']);
+ $postcode = $conn->real_escape_string($_POST['postcode']);
+
+ // Prepare SQL statement to insert data
+ $stmt = $conn->prepare("INSERT INTO student (studentid, password, dob, firstname, lastname, house, town, county, country, postcode) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+ $stmt->bind_param("ssssssssss", $studentid, $hashedPassword, $dob, $firstname, $lastname, $house, $town, $county, $country, $postcode);
+
+ // Execute the prepared statement
+ if ($stmt->execute()) {
+ echo "New record created successfully";
} else {
- echo "Invalid file type.";
- exit;
+ echo "Error: " . $stmt->error;
}
-}
-
-// Existing validation and sanitization code...
-// Modified SQL statement to include the image_path
-$sql = "INSERT INTO student (studentid, password, dob, firstname, lastname, house, town, county, country, postcode, image_path) VALUES ('$studentid', '$password', '$dob', '$firstname', '$lastname', '$house', '$town', '$county', '$country', '$postcode', '$imagePath')";
-
-// Execute SQL
-if ($conn->query($sql) === TRUE) {
- echo "New student added successfully.";
+ // Close statement
+ $stmt->close();
} else {
- echo "Error: " . $sql . " " . $conn->error;
+ echo "Invalid request method.";
}
-$conn->close();
-
?>
From 95f2d6764074cc4f45d2fc841ba4f367ef9a5703 Mon Sep 17 00:00:00 2001
From: Richard Ochei <162317835+OxheiCodes@users.noreply.github.com>
Date: Fri, 5 Apr 2024 17:34:21 +0100
Subject: [PATCH 06/13] Fixed Code with added Validations
---
_includes/dbconnect.inc | 2 +-
addstudent.php | 106 ++++++++++++++----------
assignmodule.php | 13 ++-
custom.css | 2 +-
details.php | 160 ++++++++++++++++++++-----------------
editStudent.php | 33 ++++++++
modules.php | 13 ++-
students.php | 154 ++++++++++++++++++++---------------
templates/partials/nav.php | 5 +-
updateStudent.php | 46 +++++++++++
10 files changed, 346 insertions(+), 188 deletions(-)
create mode 100644 editStudent.php
create mode 100644 updateStudent.php
diff --git a/_includes/dbconnect.inc b/_includes/dbconnect.inc
index 17f69e86..801bb08c 100644
--- a/_includes/dbconnect.inc
+++ b/_includes/dbconnect.inc
@@ -1,6 +1,6 @@
-
+
Add New Student
+
+
-
-
-
-
Add New Student
-
-
+
+
+
Add New Student
+
+
+
+
+
+
-
diff --git a/assignmodule.php b/assignmodule.php
index 83653ddc..61040894 100644
--- a/assignmodule.php
+++ b/assignmodule.php
@@ -1,4 +1,12 @@
-
+
+
+
+ Assign Module
+
+
+
+
+
+
+
diff --git a/custom.css b/custom.css
index 862d1f50..4d422d7b 100644
--- a/custom.css
+++ b/custom.css
@@ -3,7 +3,7 @@ body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 1.5;
- color: #333333;
+ color: #333333 ;
background-color: #f8f8f8;
}
diff --git a/details.php b/details.php
index 462550a2..5c0402bb 100644
--- a/details.php
+++ b/details.php
@@ -1,75 +1,87 @@
-Your details have been updated";
-
- }
- else {
- // Build a SQL statment to return the student record with the id that
- // matches that of the session variable.
- $sql = "select * from student where studentid='". $_SESSION['id'] . "';";
- $result = mysqli_query($conn,$sql);
- $row = mysqli_fetch_array($result);
-
- // using <<My Details
-
-
+
+
+
+
+
+
+ My Details
+
+
+
+
+
+
My Details
+ Your details have been updated";
+ } else {
+ // Build a SQL statement to return the student record with the id that
+ // matches that of the session variable.
+ $sql = "SELECT * FROM student WHERE studentid='" . $_SESSION['id'] . "';";
+ $result = mysqli_query($conn, $sql);
+ $row = mysqli_fetch_array($result);
+ // using <<
+