Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6c95701
first
Keiferg37 Jan 14, 2026
1f57adf
first
Keiferg37 Jan 14, 2026
60559d8
Delete test.php
Keiferg37 Jan 14, 2026
59f89b4
lab-1
Keiferg37 Jan 14, 2026
4976aae
lab one complete
Keiferg37 Jan 15, 2026
71b0c76
Merge branch 'main' into main
Keiferg37 Jan 16, 2026
b86133c
changes
Keiferg37 Jan 23, 2026
6722943
Merge branch 'main' of https://github.com/Keiferg37/COMP1006_Winter2026
Keiferg37 Jan 23, 2026
ec91795
fix
Keiferg37 Jan 23, 2026
276d384
Add initial files for lab_two including header, footer, nav, and data
Keiferg37 Jan 23, 2026
c8446e5
Merge branch 'JessicaGilfillan:main' into main
Keiferg37 Jan 30, 2026
0264cfc
Add contact form and processing logic with validation and email funct…
Keiferg37 Jan 30, 2026
aa5f72a
Fix syntax error in database connection error handling
Keiferg37 Jan 30, 2026
e5ef0c1
Merge branch 'main' of https://github.com/Keiferg37/COMP1006_Winter2026
Keiferg37 Jan 30, 2026
d0f2b24
Merge branch 'JessicaGilfillan:main' into main
Keiferg37 Feb 6, 2026
e004bfa
Merge branch 'JessicaGilfillan:main' into main
Keiferg37 Feb 13, 2026
505e01a
Add database connection script in connect.php
Keiferg37 Feb 14, 2026
8ecbd87
Refactor process.php and subscribers.php to implement database insert…
Keiferg37 Feb 14, 2026
0ae33b3
Merge branch 'main' of https://github.com/Keiferg37/COMP1006_Winter2026
Keiferg37 Feb 14, 2026
96bda89
Remove footer inclusion from subscribers.php and adjust formatting
Keiferg37 Feb 14, 2026
19a7482
Update email recipient and fix header injection vulnerability in proc…
Keiferg37 Feb 15, 2026
6fadca1
Add initial task management files: add_task.php, db.php, delete_task.…
Keiferg37 Feb 18, 2026
b504505
Add database connection script in db.php
Keiferg37 Feb 18, 2026
f157462
Add task display functionality to index.php
Keiferg37 Feb 18, 2026
efeddd1
Implement task editing functionality with server-side validation in e…
Keiferg37 Feb 18, 2026
3978f0b
Implement task deletion functionality in delete_task.php
Keiferg37 Feb 18, 2026
992fb23
Implement task addition functionality with server-side validation in …
Keiferg37 Feb 18, 2026
4d28cf6
Add reCAPTCHA verification to task submission form in add_task.php
Keiferg37 Feb 18, 2026
ab4fff3
Update reCAPTCHA secret keys in add_task.php
Keiferg37 Feb 18, 2026
9d4b6e7
Update database connection settings in db.php
Keiferg37 Feb 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 41 additions & 60 deletions 02/index.php
Original file line number Diff line number Diff line change
@@ -1,79 +1,60 @@
<?php
//make PHP strict, needs to be at the start of your script
declare(strict_types=1);
require_once "connect.php";
<?php declare(strict_types=1);

//.1 Code Commenting
//1. Set Up & Start

// inline comment

/*

multi-line comment

*/

//2. Variables, Data Types, Concatenation & Conditional Statements

$firstName = "Jessica"; //string
$lastName = "Gilfillan"; //string
$age = 40; //int
$isInstructor = true; //boolean
//2. Code Commenting

echo "<p> Hello there, my name is ". $firstName . " ". $lastName ."</p>";

if($isInstructor) {
echo "<p> I am your teacher. </p>";
}
else {
echo "<p> Whoops, teach didn't show! </p>";
}

//3. PHP is loosely typed
//create two variables, one called num1 and one called num2, in num1 store an integer and in num2 store a number but treat as string "10"

$num1 = 10; //integer
$num2 = "10"; //string

//add type hints to make PHP less loosey goosey
/*function add(int $num1, int $num2) : int {
return $num1 + $num2;
// inline comment
//3. Variables, Data Types, Concatenation, Conditional Statements & Echo

$firstName = "Keifer"; // string
$lastname = "Grainger"; // string
$age = 22; // integer
$isStudent = true; // boolean

echo "<p> Hello, my name is " . $firstName . " " . $lastname . "</p>";
if ($isStudent) {
echo "<p> I am a student </p>";
} else {
echo "<p>I am not a student.</p>";
}
//4. Loosely Typed Language Demo

echo "<p>" . add($num1,$num2) . "</p>";

*/
$num1 = 1;
$num2 = 10;

// OOP with PHP {

class Person {
public string $name;
public int $age;
public bool $isInstructor;

public function __construct(string $name, int $age, bool $isInstructor) {
$this->name = $name;
$this->age = $age;
$this->isInstructor = $isInstructor;
}

public function getBadge(): string {
$role = $this->isInstructor ? "Instructor" : "Student";
return "Name : {$this->name} | Age: {$this->age} | Role : $role";
}
function add(int $num1,int $num2) : int {
return $num1 + $num2;
}

//create an instance of the object
echo "<p>" . add($num1, $num2) . "</p>";

$person = new Person("Jessica", 40, true);

echo $person->getBadge();

echo "<p> Hello there, my name is " . $firstname . " " . $lastName . "</p>";


if ($is_student === true) {
echo "<p> I am your teacher! </p>";
} else {
echo "<p> Uh oh, teach didn't show! </p>";
}

//3. PHP is loosely typed

$num1 = 5;
$num2 = "10";

echo "<p>" . add($num1, $num2) . "</p>";

//4. Strict Types & Types Hints
/* Add declare(strict_types=1) and type hints
//strict types tell PHP not to automatically convert values when calling functions. Type hints tell PHP what to expect */

/*function add(int $num1, int $num2): int {
return $num1 + $num2;
}
echo add($num1, $num2);
*/

//6. OOP with PHP
2 changes: 1 addition & 1 deletion 03/02_fix_this_code/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@

catch (PDOException $e {
echo "Database error: " . $e
}
}
7 changes: 7 additions & 0 deletions assignments/labs/lab_four/includes/connect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
$DBH = new PDO(
"mysql:host=localhost;dbname=YOUR_DB_NAME;charset=utf8mb4",
"YOUR_DB_USER",
"YOUR_DB_PASS",
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
);
32 changes: 23 additions & 9 deletions assignments/labs/lab_four/process.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
<?php
require "includes/header.php";
// TODO: connect to the database
require "includes/connect.php"; // use the same connection file everywhere

// TODO: Grab form data (no validation or sanitization for this lab)
// TODO: connect to the database
// (connection is handled inside connect.php)

// TODO: Grab form data (no validation or sanitization for this lab)
$FIRST_NAME = $_POST["first_name"];
$LAST_NAME = $_POST["last_name"];
$EMAIL = $_POST["email"];

/*
1. Write an INSERT statement with named placeholders
2. Prepare the statement
3. Execute the statement with an array of values
4.

*/

$STMT = $DBH->prepare("
INSERT INTO subscribers (first_name, last_name, email)
VALUES (:first_name, :last_name, :email)
");

$STMT->execute([
":first_name" => $FIRST_NAME,
":last_name" => $LAST_NAME,
":email" => $EMAIL
]);
?>
<!DOCTYPE html>
<html lang="en">
Expand All @@ -28,13 +41,14 @@
<h2>Thank You for Subscribing</h2>

<!-- TODO: Display a confirmation message -->
<!-- Example: "Thanks, Name! You have been added to our mailing list." -->

<p>
Thanks, <?= htmlspecialchars($FIRST_NAME) ?>!
You have been added to our mailing list.
</p>

<p class="mt-3">
<a href="subscribers.php">View Subscribers</a>
</p>
</main>
</body>

</html>
</html>
24 changes: 18 additions & 6 deletions assignments/labs/lab_four/subscribers.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
//TODO:
require "includes/connect.php";

/*
Expand All @@ -11,7 +10,14 @@
5. Fetch all results into $subscribers
*/

$subscribers = []; // placeholder
$STMT = $DBH->prepare("
SELECT id, first_name, last_name, email, subscribed_at
FROM subscribers
ORDER BY subscribed_at DESC
");

$STMT->execute();
$subscribers = $STMT->fetchAll();
?>

<main class="container mt-4">
Expand All @@ -31,14 +37,20 @@
</tr>
</thead>
<tbody>
<!-- TODO: Loop through $subscribers and output each row -->
<?php foreach ($subscribers as $S): ?>
<tr>
<td><?= htmlspecialchars($S["id"]) ?></td>
<td><?= htmlspecialchars($S["first_name"]) ?></td>
<td><?= htmlspecialchars($S["last_name"]) ?></td>
<td><?= htmlspecialchars($S["email"]) ?></td>
<td><?= htmlspecialchars($S["subscribed_at"]) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>

<p class="mt-3">
<a href="index.php">Back to Subscribe Form</a>
</p>
</main>

<?php require "includes/footer.php"; ?>
</main>
22 changes: 22 additions & 0 deletions assignments/labs/lab_one/car.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);

// Car class definition
class Car {
// Properties
private string $make;
private string $model;
private int $year;

// Constructor
public function __construct(string $make, string $model, int $year) {
$this->make = $make;
$this->model = $model;
$this->year = $year;
}

// Method to get car details
public function getDetails(): string {
return $this->year . " " . $this->make . " " . $this->model;
}
}
21 changes: 21 additions & 0 deletions assignments/labs/lab_one/connect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
// connect.php
// Creates a PDO connection to the database

// Database connection settings
$host = "localhost";
$dbname = "lab_one"; // must match your database name in XAMPP
$user = "root"; // default XAMPP username
$pass = ""; // default XAMPP password is empty

try {
// Create new PDO connection
$db = new PDO("mysql:host=$host;port=3307;dbname=$dbname;charset=utf8", $user, $pass);
// Set error mode to exception for easier debugging
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// echo "Connected successfully"; // optional for testing
} catch (PDOException $e) {
// Display error message if connection fails
echo "Database connection failed: " . $e->getMessage();
exit;
}
1 change: 1 addition & 0 deletions assignments/labs/lab_one/footer.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<?php
// footer.php
// Shared footer content. Included from index.php.
Expand Down
29 changes: 28 additions & 1 deletion assignments/labs/lab_one/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
<?php
declare(strict_types=1);

// Include shared header HTML
require "header.php";

// Include Car class definition
require "car.php";

// Include database connection
require "connect.php";

// Create a Car object
$car = new Car("Toyota", "Corolla", 2020);

// Display car details
echo "<p>Car: " . $car->getDetails() . "</p>";

// Output instructions message
echo "<p> Follow the instructions outlined in instructions.txt to complete this lab. Good luck & have fun!😀 </p>";
require "footer.php";

/*
Reflection:
I found creating the Car class and using require statements easy
because it followed examples from class. The most challenging part
was setting up the PDO database connection and making sure XAMPP
was configured correctly.
*/

// Include shared footer HTML
require "footer.php";
Loading