Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 2 additions & 4 deletions 05/includes/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Week 4 - Form Validation </title>
<link href="styles/main.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
</head>

<body>
Expand Down
8 changes: 4 additions & 4 deletions 05/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<!-- Step One - Add Client Side Validation with HTML Attributes -->
<fieldset>
<legend>Customer Information</legend>
<label for="first_name">First name</label>
<input type="text" id="first_name" name="first_name">
<label for="first_name" class = "form-label" First name label>
<input type="text" id="first_name" name="first_name" class ="form-control">
<label for="last_name">Last name</label>
<input type="text" id="last_name" name="last_name">
<label for="phone">Phone number</label>
Expand Down Expand Up @@ -95,14 +95,14 @@
<legend>Additional Comments</legend>

<p>
<label for="comments">Comments (optional)</label><br>
<label for="comments" class="form-label">Comments (optional)</label><br>
<textarea id="comments" name="comments" rows="4"
placeholder="Allergies, delivery instructions, custom messages..."></textarea>
</p>
</fieldset>

<p>
<button type="submit">Place Order</button>
<button type="submit" class="btn btn-primary">Place Order</button>
</p>

</form>
Expand Down
36 changes: 36 additions & 0 deletions 05/process.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,42 @@
INSERT THE ORDER USING A PREPARED STATEMENT
*/

$sql = "INSERT INTO orders (first_name, last_name, phone, address, email, chaos_croissant, midnight_muffin, existential_eclair, procrastination_cookie, finals_week_brownie, victory_cinnamonn_roll, comments) VALUES (:first_name, :last_name, :phone, :address, :email, :chaos_croissant, :midnight_muffin, :existential_eclair, :procastination_cookie, :finals_week_brownie, :victory_cinnamonn_roll, :comments)";

//prepare the query
$stmt = $pdo->prepare($sql);

$chaosCroissant = $itemsOrdered['chaos_croissant'] ?? 0;
$midnightMuffin = $itemsOrdered['midnight_muffin'] ?? 0;
$existentialEclair = $itemsOrdered['existential_eclair'] ?? 0;
$procrastinationCookie = $itemsOrdered['procrastination_cookie'] ?? 0;
$finalsWeekBrownie = $itemsOrdered['finals_week_brownie'] ??

$stmt->bindParam(':first_name', $firstName);
$stmt->bindParam(':last_name', $lastName);
$stmt->bindParam(':phone', $phone);
$stmt->bindParam(':address', $address);
$stmt->bindParam(':email', $email);








//pull from $itemsOrdered amd store in variables











?>

<!--Confirmation Message -->
Expand Down
36 changes: 36 additions & 0 deletions car.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

class car
{

//Properties
public string $make;
public string $model;
public int $year;

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

//method
public function getCar(): string
{
return "Car: " . $this->year . " " . $this->make . " " . $this->model;
}













}
8 changes: 8 additions & 0 deletions footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
// footer.php
// Shared footer content. Included from index.php.
?>
<hr>
<p>COMP1006 - Week 2 Lab</p>
</body>
</html>
15 changes: 15 additions & 0 deletions header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
// header.php
// This file holds shared page header HTML.
// We include/require it from index.php to avoid repeating code.
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>COMP1006 - Lab 1</title>
</head>
<body>
<h1>COMP1006 - Lab 1</h1>
<p>Week 2: PHP OOP + Includes + PDO Connection</p>
<hr>
4 changes: 4 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
require "header.php";
echo "<p> Follow the instructions outlined in instructions.txt to complete this lab. Good luck & have fun!😀 </p>";
require "footer.php";
10 changes: 10 additions & 0 deletions instructions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Lab One Instructions:

1.) Clone or download the Lab One starter files from the course GitHub repository.
2.) Create a PHP file called car.php. In this file, create a class to represent a car. Properties should include make, model and year and include a method to return this information. Use include/require to include this code in index.php. Add comments to explain your code. (/5 marks)
3.) Instantiate a new instance of a car object and echo the car information in the browser (/2 marks)
4.) Using your local server (XAMPP, MAMP, WAMP), create a database. Create a file called connect.php and use PDO to connect to your database. Remember to include try/catch blocks to handle connection errors. Use include/require to include this code in index.php. Add comments to explain your code (/5 marks)
6.) Add a multi-line comment in index.php reflecting on which parts of the lab you found easy and which parts were challening. (/2 marks)
7.) Congrats! All done! Add me as a collaborator to your repository (username: JessicaGilfilan) and submit a github link to your completed lab on Blackboard. (/2 marks)

/16 marks
48 changes: 48 additions & 0 deletions lab 2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php



$title = "My PHP Page";
$items = ["Home", "About", "Contact"];


function view($template, $data = []) {
extract($data);
eval("?>$template<?php ");
}


$header = <<<HTML
<!DOCTYPE html>
<html>
<head>
<title><?= \$title ?></title>
</head>
<body>
HTML;

$menu = <<<HTML
<ul>
<?php foreach (\$items as \$item): ?>
<li><?= htmlspecialchars(\$item) ?></li>
<?php endforeach; ?>
</ul>
HTML;

$footer = <<<HTML
<footer>
<p>&copy; <?= date("Y") ?></p>
</footer>
</body>
</html>
HTML;

?>

<?php view($header, compact("title")); ?>

<h1>Welcome</h1>

<?php view($menu, compact("items")); ?>

<?php view($footer); ?>
8 changes: 8 additions & 0 deletions lab two.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"folders": [
{
"path": "../../../../../../../Downloads/COMP1006_Winter2026-main (real one)"
}
],
"settings": {}
}