diff --git a/.DS_Store b/.DS_Store index d29bd1f..37a21bb 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f4f4c77 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +04/.DS_Store diff --git a/03/03_make_it_maintainable/footer.php b/03/03_make_it_maintainable/footer.php new file mode 100644 index 0000000..6e35977 --- /dev/null +++ b/03/03_make_it_maintainable/footer.php @@ -0,0 +1,9 @@ + +
+

© 2026

+ + + diff --git a/03/03_make_it_maintainable/header.php b/03/03_make_it_maintainable/header.php new file mode 100644 index 0000000..b6a9b75 --- /dev/null +++ b/03/03_make_it_maintainable/header.php @@ -0,0 +1,13 @@ + + + + + + My PHP Page + + +

Welcome

+
diff --git a/03/03_make_it_maintainable/index.php b/03/03_make_it_maintainable/index.php index 5cb2b17..f73e81f 100644 --- a/03/03_make_it_maintainable/index.php +++ b/03/03_make_it_maintainable/index.php @@ -1,34 +1,30 @@ ['title' => 'Home', 'content' => 'Welcome to my PHP page.'], + 'about' => ['title' => 'About', 'content' => 'This is the About section.'], + 'contact' => ['title' => 'Contact', 'content' => 'This is the Contact section.'], +]; +$current = $_GET['page'] ?? 'home'; +if (!isset($pages[$current])) { + $current = 'home'; +} ?> - - - - My PHP Page - - + -

Welcome

+

+

- - - - - - + diff --git a/04/.DS_Store b/04/.DS_Store new file mode 100644 index 0000000..1a6a7c2 Binary files /dev/null and b/04/.DS_Store differ diff --git a/04/assets/bitumi.png b/04/assets/bitumi.png new file mode 100644 index 0000000..bb7fe53 Binary files /dev/null and b/04/assets/bitumi.png differ diff --git a/04/https-::github.com:kashefinterior-tech:COMP1006_Winter2026.git/.DS_Store b/04/https-::github.com:kashefinterior-tech:COMP1006_Winter2026.git/.DS_Store new file mode 100644 index 0000000..38de9d4 Binary files /dev/null and b/04/https-::github.com:kashefinterior-tech:COMP1006_Winter2026.git/.DS_Store differ diff --git a/04/https-::github.com:kashefinterior-tech:COMP1006_Winter2026.git/COMP1006_Winter2026 b/04/https-::github.com:kashefinterior-tech:COMP1006_Winter2026.git/COMP1006_Winter2026 new file mode 160000 index 0000000..adeb2b1 --- /dev/null +++ b/04/https-::github.com:kashefinterior-tech:COMP1006_Winter2026.git/COMP1006_Winter2026 @@ -0,0 +1 @@ +Subproject commit adeb2b11ae621630b5a430bc7672bb1e3c343754 diff --git a/04/includes/footer.php b/04/includes/footer.php new file mode 100644 index 0000000..29d99ae --- /dev/null +++ b/04/includes/footer.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/04/includes/header.php b/04/includes/header.php new file mode 100644 index 0000000..2f9d821 --- /dev/null +++ b/04/includes/header.php @@ -0,0 +1,25 @@ + + + + + + + Week 4 - Form Validation + + + + +
+

+ +

+ +
\ No newline at end of file diff --git a/04/index.php b/04/index.php new file mode 100644 index 0000000..089a679 --- /dev/null +++ b/04/index.php @@ -0,0 +1,113 @@ + +
+

Order Online - Easy & Simple (And Totally Secure...) 🧁

+
+ + +
+ Customer Information + + + + + + + + + + +
+ + +
+ Order Details + +

+ Enter a quantity for each item (use 0 if you don't want it). +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Baked TreatQuantity
Chaos Croissant 🥐 + + +
Midnight Muffin 🌙 + + +
Existential Éclair 🤔 + + +
Procrastination Cookie ⏰ + + +
Finals Week Brownie 📚 + + +
Victory Cinnamon Roll 🏆 + + +
+ +
+ +
+ Additional Comments + +

+
+ +

+
+ +

+ +

+ +
+
+ + + + + \ No newline at end of file diff --git a/04/lab-4 /css/main.css b/04/lab-4 /css/main.css new file mode 100644 index 0000000..e69de29 diff --git a/04/lab-4 /includes/footer.php b/04/lab-4 /includes/footer.php new file mode 100644 index 0000000..e69de29 diff --git a/04/lab-4 /includes/header.php b/04/lab-4 /includes/header.php new file mode 100644 index 0000000..e69de29 diff --git a/04/lab-4 /index.php b/04/lab-4 /index.php new file mode 100644 index 0000000..e69de29 diff --git a/04/lab-4 /process.php b/04/lab-4 /process.php new file mode 100644 index 0000000..e69de29 diff --git a/04/lab-4 /send_email.php b/04/lab-4 /send_email.php new file mode 100644 index 0000000..e69de29 diff --git a/04/process.php b/04/process.php new file mode 100644 index 0000000..c42c611 --- /dev/null +++ b/04/process.php @@ -0,0 +1,154 @@ +This page expects a POST form submission.

"; + exit; +} + +// --------------------------------------------------------- +// 2) Sanitize data using filter_input() +// --------------------------------------------------------- +// Instructor note: +// - filter_input() reads from INPUT_POST instead of $_POST +// - FILTER_SANITIZE_SPECIAL_CHARS prevents HTML injection +$firstName = filter_input(INPUT_POST, 'first_name', FILTER_SANITIZE_SPECIAL_CHARS); +$lastName = filter_input(INPUT_POST, 'last_name', FILTER_SANITIZE_SPECIAL_CHARS); +$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL); +$phone = filter_input(INPUT_POST, 'phone', FILTER_SANITIZE_SPECIAL_CHARS); +$address = filter_input(INPUT_POST, 'address', FILTER_SANITIZE_SPECIAL_CHARS); +$comments = filter_input(INPUT_POST, 'comments', FILTER_SANITIZE_SPECIAL_CHARS); + +// --------------------------------------------------------- +// 3) Access array-based item data +// --------------------------------------------------------- +// - filter_input() does not work well with nested arrays +// - Array inputs must be accessed directly +$items = $_POST['items'] ?? []; + +// --------------------------------------------------------- +// 4) Validate required fields +// --------------------------------------------------------- +$errors = []; + +// Required text fields +if ($firstName === null || $firstName === '') { + $errors[] = "First name is required."; +} + +if ($lastName === null || $lastName === '') { + $errors[] = "Last name is required."; +} + +// Email validation +if ($email === null || $email === '') { + $errors[] = "Email address is required."; +} elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { + $errors[] = "Email address must be a valid email."; +} + +// Phone validation (simple, teaching-friendly) +if ($phone === null || $phone === '') { + $errors[] = "Phone number is required."; +} elseif (!filter_var($phone, FILTER_VALIDATE_REGEXP, [ + 'options' => ['regexp' => '/^[0-9\-\+\(\)\s]{7,25}$/'] +])) { + $errors[] = "Phone number format is invalid."; +} + +if ($address === null || $address === '') { + $errors[] = "Address is required."; +} + +// --------------------------------------------------------- +// 5) Validate item quantities +// --------------------------------------------------------- +// Instructor note: +// - We require at least one item with quantity > 0 +$itemsOrdered = []; + +foreach ($items as $item => $quantity) { + if (filter_var($quantity, FILTER_VALIDATE_INT) !== false && $quantity > 0) { + $itemsOrdered[$item] = $quantity; + } +} + +if (count($itemsOrdered) === 0) { + $errors[] = "Please order at least one item."; +} + +// --------------------------------------------------------- +// 6) If errors exist, display them and stop +// --------------------------------------------------------- + +?> + + +
+ +

There was a problem with your order

+ + + +

+ Return to the form +

+
+ + + +

Thank You for Your Order! 🧁

+ +

+ Thanks ! + Your order has been received and sent to the bakery. +

+ +

Your Order Details

+ +

Name:

+

Phone:

+

Address:

+ +

Items Ordered

+ + +

Additional Comments

+

+ +

+ A confirmation has been sent to the bakery. +

+ + Place another order + + + \ No newline at end of file diff --git a/04/send_email.php b/04/send_email.php new file mode 100644 index 0000000..6306687 --- /dev/null +++ b/04/send_email.php @@ -0,0 +1,34 @@ + $quantity) { + $message .= "- {$item}: {$quantity}\n"; +} + +$message .= "\nAdditional Comments:\n"; +$message .= ($comments === "") ? "(none)\n" : "{$comments}\n"; + +// --------------------------------------------------------- +// Send the email +// --------------------------------------------------------- +// NOTE: +// mail() may not work on local machines without configuration. +// That’s okay — the confirmation page will still display. +$headers = "From: no-reply@bakeittillyoumakeit.example\r\n"; +mail($to, $subject, $message, $headers); +?> \ No newline at end of file diff --git a/04/styles/main.css b/04/styles/main.css new file mode 100644 index 0000000..39cf0a4 --- /dev/null +++ b/04/styles/main.css @@ -0,0 +1,134 @@ +/* ============================ + Simple Reset / Base Styles + ============================ */ + +/* Box sizing reset */ +*, +*::before, +*::after { + box-sizing: border-box; +} + +/* Remove default margins */ +body, +h1, +h2, +h3, +p, +fieldset, +legend { + margin: 0; +} + +/* Base body styles */ +body { + line-height: 1.5; + color: #222; + background-color: #fafafa; +} + +/* ============================ + Layout + ============================ */ + +main, +header nav, +footer { + max-width: 80%; + margin: 2rem auto; + padding: 1.5rem; +} + +/* ============================ + Logo / Heading + ============================ */ + +h1 { + text-align: center; + margin-bottom: 1.5rem; +} + +h1 img { + max-width: 220px; + height: auto; +} + +/* ============================ + Form Elements + ============================ */ + +fieldset { + border: 1px solid #ddd; + padding: 1rem; + margin-bottom: 1.5rem; +} + +legend { + padding: 0 0.5rem; + font-weight: 600; +} + +label { + font-weight: 500; +} + +input, +select, +textarea, +button { + display:block; + font-family: inherit; + font-size: 1rem; +} + +input, +select, +textarea { + width: 100%; + padding: 0.4rem; + margin-top: 0.25rem; +} + +textarea { + resize: vertical; +} + +/* ============================ + Navigation + ============================ */ + +nav { + margin-bottom: 1.5rem; + background-color: #333; +} + +nav ul { + list-style: none; + padding: 0; + margin: 0; + + display: flex; + gap: 1.25rem; + justify-content: center; +} + +nav a { + text-decoration: none; + color: #fff; + font-weight: 500; + padding: 0.25rem 0; +} + +nav a:hover, +nav a:focus { + text-decoration: underline; +} + +/* ============================ + Footer + ============================ */ + + footer { + background-color: #000; + color: #FFF; + } \ No newline at end of file diff --git a/assignments/.DS_Store b/assignments/.DS_Store index b723e72..f7a271a 100644 Binary files a/assignments/.DS_Store and b/assignments/.DS_Store differ diff --git a/assignments/labs/.DS_Store b/assignments/labs/.DS_Store index 1ed5283..9d019fe 100644 Binary files a/assignments/labs/.DS_Store and b/assignments/labs/.DS_Store differ