diff --git a/README.md b/README.md
deleted file mode 100644
index 10e3779e..00000000
--- a/README.md
+++ /dev/null
@@ -1,39 +0,0 @@
-# bnu-php-example
-
-This script is for students at Bucks New Uni learning PHP in the "Open Source Systems" module. It is also a good starter project for anyone who is looking to learn PHP and MySQL.
-
-## Installation Instructions
-
-1. Run the SQL commands on your database from "_sql/college.dump" to setup the database tables and initial data
-2. Download a copy of the repository files and upload them to your FTP server space in a new folder
-3. Update "_includes/dbconnect.inc" with your database login credentials
-4. Visit the your project folder in a browser and you should see a login screen
-
-## Default Login
-
-The database is initialised with the following user setup:
-
-- Student ID: 20000000
-- Password: test
-
-## What does this web app demonstrate?
-
-- how to use mysqli_ functions to connect to MySQL database
-- how you can organise your files and folders in your project (there is no one correct way, but this is one way!)
-- how to implement user authentication (login) using the PHP password_verify() function
-- how to generate a secure hash of a password (see password_hash.php)
-- how to implement a basic templating system (this, in turn, demonstrates how to separate business logic from the presentation layer)
-- how to use the \<\<\Add New Student
+
You are already assigned to the module " . $_POST['selmodule'] . ".
"; + } else { + // Insert the module assignment since it does not exist + $sql = "INSERT INTO studentmodules VALUES ('" . $_SESSION['id'] . "', '" . $_POST['selmodule'] . "');"; + $result = mysqli_query($conn, $sql); + if ($result) { + $data['content'] .= "The module " . $_POST['selmodule'] . " has been assigned to you.
"; + } else { + $data['content'] .= "Error assigning module: " . mysqli_error($conn) . "
"; + } + } + } else { + // If no module has been selected, display the module selection form + $sql = "SELECT * FROM module"; + $result = mysqli_query($conn, $sql); + $data['content'] .= ""; + } + + // Render the template with content + echo template("templates/default.php", $data); + +} else { + // Redirect to login page if not logged in + header("Location: index.php"); +} + +echo template("templates/partials/footer.php"); +?> + + diff --git a/authenticate.php b/authenticate.php index 903875a3..e024c46f 100644 --- a/authenticate.php +++ b/authenticate.php @@ -1,24 +1,24 @@ - + diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..d3f5495c --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "fakerphp/faker": "^1.23" + } +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 00000000..0b1a39f6 --- /dev/null +++ b/composer.lock @@ -0,0 +1,202 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "3fb5a307183627a23aeed132a1bec5e1", + "packages": [ + { + "name": "fakerphp/faker", + "version": "v1.23.1", + "source": { + "type": "git", + "url": "https://github.com/FakerPHP/Faker.git", + "reference": "bfb4fe148adbf78eff521199619b93a52ae3554b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/bfb4fe148adbf78eff521199619b93a52ae3554b", + "reference": "bfb4fe148adbf78eff521199619b93a52ae3554b", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "psr/container": "^1.0 || ^2.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "conflict": { + "fzaninotto/faker": "*" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "doctrine/persistence": "^1.3 || ^2.0", + "ext-intl": "*", + "phpunit/phpunit": "^9.5.26", + "symfony/phpunit-bridge": "^5.4.16" + }, + "suggest": { + "doctrine/orm": "Required to use Faker\\ORM\\Doctrine", + "ext-curl": "Required by Faker\\Provider\\Image to download images.", + "ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.", + "ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.", + "ext-mbstring": "Required for multibyte Unicode string functionality." + }, + "type": "library", + "autoload": { + "psr-4": { + "Faker\\": "src/Faker/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "support": { + "issues": "https://github.com/FakerPHP/Faker/issues", + "source": "https://github.com/FakerPHP/Faker/tree/v1.23.1" + }, + "time": "2024-01-02T13:46:09+00:00" + }, + { + "name": "psr/container", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.4-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2023-05-23T14:45:45+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/custom.css b/custom.css new file mode 100644 index 00000000..4d422d7b --- /dev/null +++ b/custom.css @@ -0,0 +1,173 @@ +/* General Styles */ +body { + font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; + font-size: 16px; + line-height: 1.5; + color: #333333 ; + background-color: #f8f8f8; + } + + /* Headings */ + h1, h2, h3, h4, h5, h6 { + font-weight: bold; + margin-top: 0; + } + + h1 { + font-size: 36px; + color: #2c3e50; + } + + h2 { + font-size: 30px; + color: #2c3e50; + } + + h3 { + font-size: 24px; + color: #2c3e50; + } + + h4 { + font-size: 18px; + color: #2c3e50; + } + + h5 { + font-size: 16px; + color: #2c3e50; + } + + h6 { + font-size: 14px; + color: #2c3e50; + } + + /* Links */ + a { + color: #2980b9; + text-decoration: none; + } + + a:hover { + color: #3498db; + text-decoration: underline; + } + + /* Buttons */ + .btn { + display: inline-block; + padding: 10px 20px; + background-color: #2980b9; + color: #ffffff; + border-radius: 4px; + text-decoration: none; + transition: background-color 0.3s ease; + } + + .btn:hover { + background-color: #3498db; + } + + /* Forms */ + input[type="text"], + input[type="email"], + input[type="password"], + textarea { + padding: 10px; + border: 1px solid #cccccc; + border-radius: 4px; + width: 100%; + box-sizing: border-box; + font-size: 16px; + } + + input[type="submit"] { + background-color: #2980b9; + color: #ffffff; + border: none; + padding: 10px 20px; + border-radius: 4px; + cursor: pointer; + transition: background-color 0.3s ease; + } + + input[type="submit"]:hover { + background-color: #3498db; + } + + /* Tables */ + table { + width: 100%; + border-collapse: collapse; + margin-bottom: 20px; + } + + th, td { + padding: 10px; + text-align: left; + border-bottom: 1px solid #dddddd; + } + + th { + background-color: #2c3e50; + color: #ffffff; + font-weight: bold; + } + + tr:nth-child(even) { + background-color: #f2f2f2; + } + + /* Form Layouts */ + fieldset { + border: 1px solid #cccccc; + padding: 20px; + margin-bottom: 20px; + } + + legend { + font-weight: bold; + font-size: 18px; + color: #2c3e50; + } + + label { + display: block; + margin-bottom: 5px; + font-weight: bold; + } + + .form-group { + margin-bottom: 15px; + } + + .form-inline .form-group { + display: inline-block; + margin-right: 10px; + } + + /* 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/deleteStudents.php b/deleteStudents.php new file mode 100644 index 00000000..b750fb2f --- /dev/null +++ b/deleteStudents.php @@ -0,0 +1,21 @@ +prepare($sql); + $stmt->bind_param("i", $studentid); + $stmt->execute(); + } + echo ""; +} else { + echo ""; +} + +?> diff --git a/details.php b/details.php index 462550a2..4f6e2528 100644 --- a/details.php +++ b/details.php @@ -1,75 +1,91 @@ -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 <<| Modules | ||
|---|---|---|
| Code | Name | Level |
| " . htmlspecialchars($row['modulecode']) . " | "; + $data['content'] .= "" . htmlspecialchars($row['name']) . " | "; + $data['content'] .= "" . htmlspecialchars($row['level']) . " |