Compare commits
28 Commits
59948ed75c
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 59e0329d1e | |||
| a747e2a1d9 | |||
| 015ea75186 | |||
| ee2a792c56 | |||
| e2aa277aaf | |||
| 9daa37287f | |||
| a253f3ffb2 | |||
| 942da76704 | |||
| f3667266a9 | |||
| fd7b36e76a | |||
| 8c78e75b97 | |||
| 8b132e776f | |||
| b732795717 | |||
| 41ebd4ac62 | |||
| 1fdfbb1b4f | |||
| a7b70a2a55 | |||
| f186c94048 | |||
| ae48ceff91 | |||
| 05116ea9b9 | |||
| 71a5d36a7a | |||
| 1357b2362a | |||
| 064cff7cfc | |||
| 4b1b63befb | |||
| 8b7df42d74 | |||
| 49f188ff7d | |||
| 62b5583957 | |||
| 050db847ca | |||
| c88c9bbeea |
@@ -1 +1,3 @@
|
||||
INFO-3174 (Web Security)/kali-linux-2025.4-vmware-amd64.vmwarevm
|
||||
INFO-3174 (Web Security)/kali-linux-2025.4-vmware-amd64.vmwarevm
|
||||
*.mp4
|
||||
*.mkv
|
||||
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 30 KiB |
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// Create first variables, sanitized
|
||||
$firstName = filter_var($_POST['fname'], FILTER_SANITIZE_STRING);
|
||||
$lastName = filter_var($_POST['lname'], FILTER_SANITIZE_STRING);
|
||||
$favMovie = filter_var($_POST['favMovie'], FILTER_SANITIZE_STRING);
|
||||
$favMovieSnack = filter_var($_POST['favMovieSnack'], FILTER_SANITIZE_STRING);
|
||||
$seatPref = filter_var($_POST['seatPref'], FILTER_SANITIZE_STRING);
|
||||
$genFeedback = filter_var($_POST['genFeedback'], FILTER_SANITIZE_STRING);
|
||||
|
||||
// Create full name variable and urlencode it
|
||||
$fullName = $firstName . " " . $lastName;
|
||||
$nameEncoded = urlencode($fullName);
|
||||
|
||||
// Filter for newlines
|
||||
$genFeedback = nl2br($genFeedback);
|
||||
|
||||
// Replace the mean words
|
||||
$genFeedback = str_ireplace("bad","good",$genFeedback);
|
||||
$genFeedback = str_ireplace("horrible","amazing",$genFeedback);
|
||||
|
||||
// Create a message variable (I just like this way more)
|
||||
$message = "<p>Thank you for your feedback! Below are your survey results:</p>
|
||||
<p>Full Name: $fullName</p>
|
||||
<p>Favourite Movie: $favMovie</p>
|
||||
<p>Favourite Movie Snack: $favMovieSnack</p>
|
||||
<p>Theatre Seat Row Preference: $seatPref</p>
|
||||
<p>General Feedback: $genFeedback</p>
|
||||
<p>Click <a href=\"lab5.php?fullName=$nameEncoded\">Here</a> to return to the survey.</p>";
|
||||
|
||||
// Print the message
|
||||
print($message);
|
||||
?>
|
||||
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Lab 5 Page 1</title>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Movie Theatre Survey</h1>
|
||||
|
||||
<form action="lab5-1.php" method="post">
|
||||
<label for="fname">First Name:</label>
|
||||
<input type="text" name="fname"><br>
|
||||
<label for="lname">Last Name:</label>
|
||||
<input type="text" name="lname"><br>
|
||||
<label for="favMovie">Favourite Movie:</label>
|
||||
<input type="text" name="favMovie"><br>
|
||||
<label for="favMovieSnack">Favourite Movie Snack:</label>
|
||||
<input type="text" name="favMovieSnack"><br>
|
||||
<label for="seatPref">Theatre Seat Row Preference:</label>
|
||||
<select name="seatPref">
|
||||
<option value="Back">Back</option>
|
||||
<option value="Middle">Middle</option>
|
||||
<option value="Front">Front</option>
|
||||
</select><br>
|
||||
<label for="genFeedback">General Feedback:</label>
|
||||
<textarea name="genFeedback"></textarea><br>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 67 KiB |
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
// Get and print age, print error if empty
|
||||
|
||||
if (!isset($_POST["ageInput"]) || $_POST["ageInput"] === "") {
|
||||
print("Please enter a valid age above or equal to 0<br>");
|
||||
} else {
|
||||
$userAge = $_POST["ageInput"];
|
||||
$birthYear = date("Y") - $userAge;
|
||||
if ($userAge < 0) {
|
||||
print("Please enter a valid age above or equal to 0");
|
||||
} else {
|
||||
print("Your age is " . $userAge . "<br>");
|
||||
|
||||
// Two ways to determine even-ness
|
||||
$isEven = ($userAge % 2 === 0) ? "Your age is even<br>" : "Your age is odd<br>";
|
||||
print($isEven);
|
||||
|
||||
// OR
|
||||
// if ($userAge % 2 === 0) {
|
||||
// print("Your name is even<br>");
|
||||
// } else {
|
||||
// print("Your name is odd<br>");
|
||||
// }
|
||||
|
||||
// Print age "category"
|
||||
if ($userAge <= 12) {
|
||||
print("You are a child<br>");
|
||||
} else if ($userAge > 12 && $userAge <= 17) {
|
||||
print("You are a teenager<br>");
|
||||
} else if ($userAge > 17 && $userAge <= 54) {
|
||||
print("You are an adult<br>");
|
||||
} else {
|
||||
print("You are a senior<br>");
|
||||
}
|
||||
|
||||
// Print significant events with switch statement
|
||||
switch ($birthYear) {
|
||||
case 1969:
|
||||
print("You were born the same year as the moon landing<br>");
|
||||
break;
|
||||
case 1983:
|
||||
print("You were born the same year as the creation of the internet<br>");
|
||||
break;
|
||||
case 1986:
|
||||
print("You were born the same year as the Challenger explosion<br>");
|
||||
break;
|
||||
case 2000:
|
||||
print("You were born the same year as Y2K<br>");
|
||||
break;
|
||||
case 2020:
|
||||
print("You were born the same year as the COVID-19 pandemic<br>");
|
||||
break;
|
||||
default:
|
||||
print("You were not born in any significant year<br>");
|
||||
break;
|
||||
}
|
||||
|
||||
// Print age number of hearts
|
||||
for ($i = 0; $i < $userAge; $i++) {
|
||||
print("♥");
|
||||
}
|
||||
|
||||
print("<br>");
|
||||
|
||||
// Print 100 - age number of stars
|
||||
for ($i = 0; $i < (100 - $userAge); $i++) {
|
||||
print("☆");
|
||||
}
|
||||
|
||||
print("<br>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>PHP Lab 6</title>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Age Result Generator</h1>
|
||||
<form method="post">
|
||||
<label for="ageInput">Please enter your age:</label>
|
||||
<input name="ageInput" type="number"><br>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 89 KiB |
@@ -0,0 +1,103 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>PHP Lab 7</title>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Months of the Year</h1>
|
||||
<?php
|
||||
$months = [
|
||||
1 => "January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December"
|
||||
];
|
||||
|
||||
print_r($months);
|
||||
|
||||
echo "<br><br>";
|
||||
|
||||
$months[13] = "Winter";
|
||||
$months[14] = "Construction";
|
||||
|
||||
foreach ($months as $type => $value) {
|
||||
echo "The month of $value is month number $type<br>";
|
||||
}
|
||||
?>
|
||||
|
||||
<h1>Pizza Toppings</h1>
|
||||
|
||||
<?php
|
||||
$vegetables = [
|
||||
"Green Peppers",
|
||||
"Mushrooms",
|
||||
"Olives",
|
||||
"Chives"
|
||||
];
|
||||
$meats = [
|
||||
"Pepperoni",
|
||||
"Ham",
|
||||
"Bacon"
|
||||
];
|
||||
$cheeses = [
|
||||
"Mozzarella",
|
||||
"Cheddar",
|
||||
"Provologne"
|
||||
];
|
||||
|
||||
$toppings = [
|
||||
"Vegetables" => $vegetables,
|
||||
"Meats" => $meats,
|
||||
"Cheeses" => $cheeses
|
||||
];
|
||||
|
||||
foreach ($toppings as $type => $value) {
|
||||
echo "$type: ";
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $number => $topping) {
|
||||
echo "$topping, ";
|
||||
}
|
||||
} else {
|
||||
echo "$type is $value<br>";
|
||||
}
|
||||
echo "<br>";
|
||||
};
|
||||
|
||||
echo "<br>";
|
||||
|
||||
$prices = [
|
||||
"Small" => 6.99,
|
||||
"Medium" => 8.99,
|
||||
"Large" => 13.99,
|
||||
"X-Large" => 18.99,
|
||||
"Supersize" => 22.99
|
||||
];
|
||||
|
||||
asort($prices);
|
||||
|
||||
foreach ($prices as $type => $value) {
|
||||
echo "$type: $value<br>";
|
||||
};
|
||||
|
||||
echo "<br>";
|
||||
|
||||
ksort($prices);
|
||||
|
||||
foreach ($prices as $type => $value) {
|
||||
echo "$type: $value<br>";
|
||||
};
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 76 KiB |
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 74 KiB |
|
After Width: | Height: | Size: 75 KiB |
|
After Width: | Height: | Size: 85 KiB |
@@ -0,0 +1,95 @@
|
||||
body {
|
||||
font-family: "Roboto", sans-serif;
|
||||
font-style: normal;
|
||||
font-size: 20px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #555555;
|
||||
}
|
||||
|
||||
/* Header Styles */
|
||||
header .logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
header .logo i {
|
||||
display: block;
|
||||
color: teal;
|
||||
font-size: 3rem;
|
||||
}
|
||||
|
||||
header .logo span {
|
||||
color: #666677;
|
||||
font-size: 2rem;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
header .logo span strong {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
header nav {
|
||||
background-color: teal;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
header nav ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
header nav ul li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
header nav ul li a {
|
||||
display: block;
|
||||
padding: 0.75rem;
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
header nav ul li a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
header nav ul li a.active {
|
||||
color: teal;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
/* Main Styles */
|
||||
main {
|
||||
display: block;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
main h1 {
|
||||
color: #666677;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Footer Styles */
|
||||
footer {
|
||||
display: block;
|
||||
padding: 1.5rem 1rem;
|
||||
background-color: teal;
|
||||
color: rgba(255, 255, 255, 0.75);
|
||||
text-align: center;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
footer strong {
|
||||
font-weight: 600;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
}
|
||||
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,4 @@
|
||||
<?php define("TITLE", "Best Pizza In The World!"); ?>
|
||||
<?php include("template/header.php"); ?>
|
||||
<p>This is the content of the home page.</p>
|
||||
<?php include("template/footer.php"); ?>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
define("TITLE", "User Login");
|
||||
include("template/header.php");
|
||||
print("<h2>Login Form<h2>");
|
||||
|
||||
$formStart = "<form class='login' action='login.php' method='post'>";
|
||||
$emailLabel = "<label for='email'>Email:</label>";
|
||||
$emailInput = "<input type='email' name='email'>";
|
||||
$passLabel = "<label for='pass'>Password:</label>";
|
||||
$passInput = "<input type='password' name='pass'>";
|
||||
$submit = "<input type='submit' name='submit' value='Log In'>";
|
||||
$formEnd = "</form";
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$email = htmlspecialchars($_POST['email']);
|
||||
$password = htmlspecialchars($_POST['pass']);
|
||||
|
||||
$stickyForm = $formStart .
|
||||
$emailLabel . $emailInput .
|
||||
$passLabel . $passInput .
|
||||
$submit .
|
||||
$formEnd;
|
||||
|
||||
if (!empty($email) && !empty($password)) {
|
||||
if ((strtolower($email) == 'test@test.com') && ($password == 'test')) {
|
||||
ob_end_clean();
|
||||
header('Location: specials.php');
|
||||
exit();
|
||||
} else {
|
||||
print("<p>Email or password is incorrect. Please try again.</p>" . $stickyForm);
|
||||
}
|
||||
} else {
|
||||
print("<p>Email and password are required. Please try again.</p>" . $stickyForm);
|
||||
}
|
||||
} else {
|
||||
print($stickyForm = $formStart .
|
||||
$emailLabel . $emailInput .
|
||||
$passLabel . $passInput .
|
||||
$submit .
|
||||
$formEnd);
|
||||
}
|
||||
|
||||
include("template/footer.php");
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
define("TITLE", "Today's Specials");
|
||||
date_default_timezone_set("America/Toronto");
|
||||
$date = date("l F j Y");
|
||||
$message = "<h2>These are our specails for $date:</h2>
|
||||
<p>Extra Large Meat Lovers Pizza - $17.99</p>
|
||||
<p>Toppings:</p>
|
||||
<ul>
|
||||
<li>Pepperoni</li>
|
||||
<li>Bacon</li>
|
||||
<li>Ham</li>
|
||||
<li>Mozzarella Cheese</li>
|
||||
</ul>";
|
||||
include("template/header.php");
|
||||
print($message);
|
||||
include("template/footer.php");
|
||||
@@ -0,0 +1,14 @@
|
||||
<!-- Footer -->
|
||||
<footer class="siteFooter">
|
||||
<p>
|
||||
<strong>© 2025</strong>l_mclean215318's Pizza. All rights reserved.
|
||||
</p>
|
||||
<?php
|
||||
date_default_timezone_set("America/Toronto");
|
||||
print(date("l F j, Y"));
|
||||
?>
|
||||
</footer>
|
||||
|
||||
<?php
|
||||
ob_end_flush();
|
||||
?>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
ob_start();
|
||||
?>
|
||||
<!-- Header -->
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="css/styles.css">
|
||||
<title><?php if (defined("TITLE")) {
|
||||
print(TITLE);
|
||||
} else {
|
||||
print("l_mclean215318's Pizza");
|
||||
} ?></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header class="siteHeader">
|
||||
<section>
|
||||
<h1 class="logo">
|
||||
<a href="index.php">
|
||||
<img src="images/logo.png" alt="Pizza logo">
|
||||
l_mclean215318's Pizza
|
||||
</a>
|
||||
</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#">Place Order</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">Menu</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="specials.php">Specials</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="login.php">Register</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</section>
|
||||
</header>
|
||||
</body>
|
||||
@@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="css/styles.css">
|
||||
<title>l_mclean215318's Webpage</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<header class="siteHeader">
|
||||
<section>
|
||||
<h1 class="logo">
|
||||
<a href="index.php">
|
||||
<img src="images/logo.png" alt="Pizza logo">
|
||||
l_mclean215318's Pizza
|
||||
</a>
|
||||
</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="order.php">Place Order</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">Menu</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">Specials</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">Register</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</section>
|
||||
</header>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="siteContent">
|
||||
<h1>Welcome</h1>
|
||||
<p>This is the content of the home page.</p>
|
||||
</main>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="siteFooter">
|
||||
<p>
|
||||
<strong>© 2025</strong>l_mclean215318's Pizza. All rights reserved.
|
||||
</p>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 125 KiB |
|
After Width: | Height: | Size: 114 KiB |
|
After Width: | Height: | Size: 107 KiB |
@@ -0,0 +1,95 @@
|
||||
body {
|
||||
font-family: "Roboto", sans-serif;
|
||||
font-style: normal;
|
||||
font-size: 20px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #555555;
|
||||
}
|
||||
|
||||
/* Header Styles */
|
||||
header .logo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
header .logo i {
|
||||
display: block;
|
||||
color: teal;
|
||||
font-size: 3rem;
|
||||
}
|
||||
|
||||
header .logo span {
|
||||
color: #666677;
|
||||
font-size: 2rem;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
header .logo span strong {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
header nav {
|
||||
background-color: teal;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
header nav ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
header nav ul li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
header nav ul li a {
|
||||
display: block;
|
||||
padding: 0.75rem;
|
||||
color: #ffffff;
|
||||
text-decoration: none;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
header nav ul li a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
header nav ul li a.active {
|
||||
color: teal;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
/* Main Styles */
|
||||
main {
|
||||
display: block;
|
||||
padding: 2rem;
|
||||
}
|
||||
|
||||
main h1 {
|
||||
color: #666677;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Footer Styles */
|
||||
footer {
|
||||
display: block;
|
||||
padding: 1.5rem 1rem;
|
||||
background-color: teal;
|
||||
color: rgba(255, 255, 255, 0.75);
|
||||
text-align: center;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
footer strong {
|
||||
font-weight: 600;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
}
|
||||
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,4 @@
|
||||
<?php define("TITLE", "Best Pizza In The World!"); ?>
|
||||
<?php include("template/header.php"); ?>
|
||||
<p>This is the content of the home page.</p>
|
||||
<?php include("template/footer.php"); ?>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
define("TITLE", "User Login");
|
||||
include("template/header.php");
|
||||
print("<h2>Login Form<h2>");
|
||||
|
||||
$formStart = "<form class='login' action='login.php' method='post'>";
|
||||
$emailLabel = "<label for='email'>Email:</label>";
|
||||
$emailInput = "<input type='email' name='email'>";
|
||||
$passLabel = "<label for='pass'>Password:</label>";
|
||||
$passInput = "<input type='password' name='pass'>";
|
||||
$submit = "<input type='submit' name='submit' value='Log In'>";
|
||||
$formEnd = "</form";
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$email = htmlspecialchars($_POST['email']);
|
||||
$password = htmlspecialchars($_POST['pass']);
|
||||
|
||||
$stickyForm = $formStart .
|
||||
$emailLabel . $emailInput .
|
||||
$passLabel . $passInput .
|
||||
$submit .
|
||||
$formEnd;
|
||||
|
||||
if (!empty($email) && !empty($password)) {
|
||||
if ((strtolower($email) == 'test@test.com') && ($password == 'test')) {
|
||||
session_start();
|
||||
$_SESSION['email'] = $_POST['email'];
|
||||
$_SESSION['loggedin'] = time();
|
||||
ob_end_clean();
|
||||
header('Location: menu.php');
|
||||
exit();
|
||||
} else {
|
||||
print("<p>Email or password is incorrect. Please try again.</p>" . $stickyForm);
|
||||
}
|
||||
} else {
|
||||
print("<p>Email and password are required. Please try again.</p>" . $stickyForm);
|
||||
}
|
||||
} else {
|
||||
print($stickyForm = $formStart .
|
||||
$emailLabel . $emailInput .
|
||||
$passLabel . $passInput .
|
||||
$submit .
|
||||
$formEnd);
|
||||
}
|
||||
|
||||
include("template/footer.php");
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
session_start();
|
||||
session_unset();
|
||||
session_destroy();
|
||||
define("TITLE", "Pizza Site Logout");
|
||||
include("template/header.php");
|
||||
?>
|
||||
<p>You have logged out. <a href="index.php">Click here to log in again</a>.</p>
|
||||
|
||||
<?php include("template/footer.php"); ?>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php define("TITLE", "The Best Pizza Menu in The World"); ?>
|
||||
<?php session_start(); ?>
|
||||
<?php include("template/header.php"); ?>
|
||||
<?php date_default_timezone_set("America/Toronto"); ?>
|
||||
<?php
|
||||
echo "Hello, " . $_SESSION['email'];
|
||||
echo "<br>";
|
||||
echo "You logged in at: " . date("l F j, Y, g:i A", $_SESSION['loggedin']);
|
||||
echo "<br>";
|
||||
?>
|
||||
<a href="logout.php">Logout</a>
|
||||
<?php include("template/footer.php"); ?>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
define("TITLE", "Today's Specials");
|
||||
date_default_timezone_set("America/Toronto");
|
||||
$date = date("l F j Y");
|
||||
$message = "<h2>These are our specails for $date:</h2>
|
||||
<p>Extra Large Meat Lovers Pizza - $17.99</p>
|
||||
<p>Toppings:</p>
|
||||
<ul>
|
||||
<li>Pepperoni</li>
|
||||
<li>Bacon</li>
|
||||
<li>Ham</li>
|
||||
<li>Mozzarella Cheese</li>
|
||||
</ul>";
|
||||
include("template/header.php");
|
||||
print($message);
|
||||
include("template/footer.php");
|
||||
@@ -0,0 +1,14 @@
|
||||
<!-- Footer -->
|
||||
<footer class="siteFooter">
|
||||
<p>
|
||||
<strong>© 2025</strong>l_mclean215318's Pizza. All rights reserved.
|
||||
</p>
|
||||
<?php
|
||||
date_default_timezone_set("America/Toronto");
|
||||
print(date("l F j, Y"));
|
||||
?>
|
||||
</footer>
|
||||
|
||||
<?php
|
||||
ob_end_flush();
|
||||
?>
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
ob_start();
|
||||
?>
|
||||
<!-- Header -->
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="css/styles.css">
|
||||
<title><?php if (defined("TITLE")) {
|
||||
print(TITLE);
|
||||
} else {
|
||||
print("l_mclean215318's Pizza");
|
||||
} ?></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header class="siteHeader">
|
||||
<section>
|
||||
<h1 class="logo">
|
||||
<a href="index.php">
|
||||
<img src="images/logo.png" alt="Pizza logo">
|
||||
l_mclean215318's Pizza
|
||||
</a>
|
||||
</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="#">Place Order</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="menu.php">Menu</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="specials.php">Specials</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="login.php">Register</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</section>
|
||||
</header>
|
||||
</body>
|
||||
@@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" type="text/css" href="css/styles.css">
|
||||
<title>l_mclean215318's Webpage</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Header -->
|
||||
<header class="siteHeader">
|
||||
<section>
|
||||
<h1 class="logo">
|
||||
<a href="index.php">
|
||||
<img src="images/logo.png" alt="Pizza logo">
|
||||
l_mclean215318's Pizza
|
||||
</a>
|
||||
</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="order.php">Place Order</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">Menu</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">Specials</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">Register</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</section>
|
||||
</header>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="siteContent">
|
||||
<h1>Welcome</h1>
|
||||
<p>This is the content of the home page.</p>
|
||||
</main>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="siteFooter">
|
||||
<p>
|
||||
<strong>© 2025</strong>l_mclean215318's Pizza. All rights reserved.
|
||||
</p>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
if (isset($_POST['font_size']) && isset($_POST['font_color'])) {
|
||||
setcookie('fontsize', $_POST['font_size']);
|
||||
setcookie('fontcolor', $_POST['font_color']);
|
||||
$message = "Your settings have beens set!";
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Customize Your Settings</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
if (isset($message)) {
|
||||
echo $message;
|
||||
}
|
||||
?>
|
||||
<p>Use this form to customize your settings:</p>
|
||||
<form action="customize.php" method="post">
|
||||
<select name="font_size">
|
||||
<option selected value="">Font Size</option>
|
||||
<option value="xl">Extra Large</option>
|
||||
<option value="l">Large</option>
|
||||
<option value="m">Medium</option>
|
||||
<option value="s">Small</option>
|
||||
<option value="xs">Extra Small</option>
|
||||
</select>
|
||||
<select name="font_color">
|
||||
<option selected value="">Font Color</option>
|
||||
<option value="black">Black</option>
|
||||
<option value="red">Red</option>
|
||||
<option value="blue">Blue</option>
|
||||
</select>
|
||||
<input type="submit" name="submit" value="Set my preferences">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,59 @@
|
||||
<!-- Below is a header -->
|
||||
<h1>This is a header!</h1>
|
||||
|
||||
<!-- Below is a header.
|
||||
It is a very important header. -->
|
||||
<h1> This is still a header! </h1>
|
||||
|
||||
<form action="submit.php" method="post">
|
||||
<!-- Text input -->
|
||||
<label>Text</label>
|
||||
<input type="text" name="desc">
|
||||
<br><br>
|
||||
|
||||
<!-- Textarea -->
|
||||
<label>Textarea</label>
|
||||
<textarea name="desc-2"></textarea>
|
||||
<br><br>
|
||||
|
||||
<!-- Select -->
|
||||
<label>Select</label>
|
||||
<select name="food">
|
||||
<option value="burger">Burger</option>
|
||||
<option value="pizza">Pizza</option>
|
||||
<option value="pie">Pie</option>
|
||||
</select>
|
||||
<br><br>
|
||||
|
||||
<!-- Checkbox -->
|
||||
<label>Checkbox</label>
|
||||
<input type="checkbox" value="purple">
|
||||
<br><br>
|
||||
|
||||
<!-- Radio button -->
|
||||
<label>Radio</label>
|
||||
<input type="radio" value="yes">
|
||||
<br><br>
|
||||
|
||||
<!-- Button -->
|
||||
<button type="button" onclick="alert('Hello')">Alert</button>
|
||||
<br><br>
|
||||
|
||||
<!-- Example -->
|
||||
<label>Grade</label>
|
||||
<input type="text" name="grade">
|
||||
<br><br>
|
||||
|
||||
<button type="submit">Submit</button>
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
# PHP comment with hashtag.
|
||||
// PHP comment with two slashes.
|
||||
/*
|
||||
Multi-line
|
||||
PHP comment
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
// empty().
|
||||
// isset().
|
||||
// is_numeric().
|
||||
if (
|
||||
!empty($_POST['grade']) &&
|
||||
isset($_POST['grade']) &&
|
||||
is_numeric($_POST['grade'])
|
||||
) {
|
||||
$grade = $_POST['grade'];
|
||||
print_r($grade);
|
||||
}
|
||||
else {
|
||||
echo 'Grade not provided and/or was not numeric!';
|
||||
}
|
||||
|
||||
// Strip Tags.
|
||||
$text = 'Hello <b><em>world!</em></b>';
|
||||
echo $text;
|
||||
echo strip_tags($text);
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
// All of the following will give the same result.
|
||||
echo 123 + 1;
|
||||
echo '<br>';
|
||||
echo "123" + 1;
|
||||
echo '<br>';
|
||||
echo "123" + "1";
|
||||
echo '<br><br>';
|
||||
|
||||
// Arithmetic operators.
|
||||
echo '<strong>Arithmetic operators</strong><br>';
|
||||
echo 'Addition (+) ' . 1 + 2 . '<br>';
|
||||
echo 'Subtraction (-) ' . 2 - 1 . '<br>';
|
||||
echo 'Multiplication (*) ' . 2 * 2 . '<br>';
|
||||
echo 'Division (/) ' . 4 / 2 . '<br>';
|
||||
echo 'Modulus (%) ' . 4 % 2 . '<br>';
|
||||
$a = 1;
|
||||
$a++;
|
||||
echo 'Increment (++) ' . $a . '<br>';
|
||||
$a--;
|
||||
echo 'Decrement (--) ' . $a . '<br>';
|
||||
echo '<br>';
|
||||
|
||||
// Assignment operators.
|
||||
echo '<strong>Assignment operators</strong><br>';
|
||||
$a = 2;
|
||||
echo $a . '<br>';
|
||||
$a += 2;
|
||||
echo $a . '<br>';
|
||||
$a -= 2;
|
||||
echo $a . '<br>';
|
||||
$a *= 2;
|
||||
echo $a . '<br>';
|
||||
$a /= 2;
|
||||
echo $a . '<br>';
|
||||
echo '<br>';
|
||||
|
||||
// Comparison operators.
|
||||
echo '<strong>Comparison operators</strong><br>';
|
||||
$a = 1;
|
||||
$b = 2;
|
||||
$c = '2';
|
||||
|
||||
echo ($a < $b) . '<br>';
|
||||
echo ($a > $b) . '<br>';
|
||||
echo ($a == $b) . '<br>';
|
||||
echo ($a != $b) . '<br>';
|
||||
echo ($b == $c) . '<br>';
|
||||
echo ($b === $c) . '<br>';
|
||||
echo '<br>';
|
||||
|
||||
// Formatting numbers.
|
||||
echo '<strong>Formatting numbers</strong><br>';
|
||||
|
||||
echo 'Round (2.49): ' . round(2.49) . '<br>';
|
||||
echo 'Number Format (21233122):' . number_format(21233122) . '<br>';
|
||||
echo 'Printf: ';
|
||||
$sub = 5;
|
||||
$tax = 0.65;
|
||||
printf('The subtotal is %u, making the tax
|
||||
%.2f.', $sub, $tax);
|
||||
echo '<br>';
|
||||
echo 'Mt Rand: ' . mt_rand(0, 100);
|
||||
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
/* String Concatenation. */
|
||||
|
||||
// Using the dot (.) operator
|
||||
$string1 = 'Hello';
|
||||
$string2 = 'World';
|
||||
$concatenation = $string1 . $string2;
|
||||
echo $concatenation;
|
||||
echo '<br><br>';
|
||||
|
||||
// Using the concatenation assignment operator (.=)
|
||||
$string1 = 'Hello';
|
||||
$string2 = 'World';
|
||||
$string1 .= ' ' . $string2;
|
||||
echo $string1;
|
||||
echo '<br><br>';
|
||||
|
||||
// Using double quotes (") to directly concatenate variables within a string
|
||||
$string1 = 'Hello';
|
||||
$string2 = 'World';
|
||||
$concatenation = "$string1 $string2";
|
||||
echo $concatenation;
|
||||
echo '<br><br>';
|
||||
|
||||
/* Newlines */
|
||||
|
||||
// Using the "\n" escape sequence
|
||||
echo "Line 1\nLine 2\nLine 3";
|
||||
echo '<br><br>';
|
||||
|
||||
// Using double quotes (")
|
||||
echo "Line 1
|
||||
Line 2
|
||||
Line 3";
|
||||
echo '<br><br>';
|
||||
|
||||
// Using PHP_EOL constant, which represents the correct end-of-line character
|
||||
echo "Line 1" . PHP_EOL . "Line 2" . PHP_EOL . "Line 3";
|
||||
echo '<br><br>';
|
||||
|
||||
// Using the nl2br() function to insert HTML line breaks (\n) before all newlines in a string
|
||||
$text = "Line 1\nLine 2\nLine 3";
|
||||
echo nl2br($text);
|
||||
echo '<br><br>';
|
||||
|
||||
/* Handling HTML String Input */
|
||||
|
||||
// htmlspecialchars()
|
||||
$string = "<a href='test'>Test & 'Example'</a>";
|
||||
$safe_string = htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
|
||||
echo $safe_string;
|
||||
echo '<br><br>';
|
||||
|
||||
// htmlentities()
|
||||
$string = "<a href='test'>Test & 'Example'</a>";
|
||||
$safe_string = htmlentities($string, ENT_QUOTES, 'UTF-8');
|
||||
echo $safe_string;
|
||||
echo '<br><br>';
|
||||
|
||||
/* Encoding and Decoding */
|
||||
|
||||
// Encode
|
||||
$url = urlencode("https://fanshawec.ca?programs=iwd&cpa");
|
||||
echo $url;
|
||||
echo '<br><br>';
|
||||
|
||||
// Decode
|
||||
$url = urldecode("https%3A%2F%2Ffanshawec.ca%3Fprograms%3Diwd%26cpa");
|
||||
echo $url;
|
||||
echo '<br><br>';
|
||||
|
||||
/* Adjusting strings */
|
||||
|
||||
// substr()
|
||||
$string = "You are a wizard, Harry.";
|
||||
$substr = substr($string, 9, 6);
|
||||
echo $substr;
|
||||
echo '<br><br>';
|
||||
|
||||
// strtok()
|
||||
$string = "Luke, I am your father.";
|
||||
$substr = strtok($string, ",");
|
||||
echo $substr;
|
||||
echo '<br><br>';
|
||||
|
||||
// strlen()
|
||||
$string = "May the odds be ever in your favour.";
|
||||
$length = strlen($string);
|
||||
echo $length;
|
||||
echo '<br><br>';
|
||||
|
||||
// Uppercase / Lowercase
|
||||
$string = "hello world";
|
||||
echo ucfirst($string);
|
||||
echo '<br><br>';
|
||||
echo ucwords($string);
|
||||
echo '<br><br>';
|
||||
echo strtoupper($string);
|
||||
echo '<br><br>';
|
||||
echo strtolower('HELLO WORLD');
|
||||
echo '<br><br>';
|
||||
|
||||
/* Replacing Strings */
|
||||
|
||||
// str_replace()
|
||||
$search = 'world';
|
||||
$replace = 'everyone';
|
||||
$subject = 'Hello world!';
|
||||
echo str_replace($search, $replace, $subject);
|
||||
echo '<br><br>';
|
||||
|
||||
// str_ireplace()
|
||||
$search = 'WORLD';
|
||||
$replace = 'everyone';
|
||||
$subject = 'Hello world!';
|
||||
echo str_ireplace($search, $replace, $subject);
|
||||
echo '<br><br>';
|
||||
|
||||
// trim()
|
||||
$string = " hello world ";
|
||||
echo trim($string);
|
||||
echo '<br><br>';
|
||||
|
||||
// rtrim()
|
||||
$string = "hello world!!!";
|
||||
echo rtrim($string, '!');
|
||||
echo '<br><br>';
|
||||
|
||||
$string = " hello world";
|
||||
echo ltrim($string);
|
||||
echo '<br><br>';
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
// -----------------------------
|
||||
// IF statement
|
||||
// -----------------------------
|
||||
|
||||
if ($condition) {
|
||||
// code.
|
||||
}
|
||||
|
||||
// E.g.
|
||||
if ($year === 2024) {
|
||||
$isOlympicYear = TRUE;
|
||||
}
|
||||
|
||||
// Bonus: IF statements with a lot of conditions
|
||||
if (
|
||||
$condition_1 &&
|
||||
(
|
||||
$condition_2 ||
|
||||
$condition_3
|
||||
) &&
|
||||
$condition_4
|
||||
) {
|
||||
// code.
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// IF/ELSE statement
|
||||
// -----------------------------
|
||||
|
||||
if ($condition) {
|
||||
// code.
|
||||
}
|
||||
else {
|
||||
// other code.
|
||||
}
|
||||
|
||||
// E.g.
|
||||
if ($year === 2024) {
|
||||
$isOlympicYear = TRUE;
|
||||
}
|
||||
else {
|
||||
$isOlympicYear = FALSE;
|
||||
}
|
||||
|
||||
// Alternatively, you could write the above like this.
|
||||
$isOlympicYear = FALSE;
|
||||
if ($year === 2024) {
|
||||
$isOlympicYear = TRUE;
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// ELSEIF statements.
|
||||
// -----------------------------
|
||||
|
||||
if ($condition_1) {
|
||||
// code.
|
||||
}
|
||||
elseif ($condition_2) {
|
||||
// other code.
|
||||
}
|
||||
else {
|
||||
// other other code.
|
||||
}
|
||||
|
||||
// E.g.
|
||||
if ($year === 2024) {
|
||||
$isOlympicYear = TRUE;
|
||||
}
|
||||
elseif ($year === 2025) {
|
||||
$isOlympicYear = FALSE;
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// Nesting statements
|
||||
// -----------------------------
|
||||
|
||||
// E.g.
|
||||
if ($year === 2024) {
|
||||
$isOlympicYear = TRUE;
|
||||
|
||||
if ($city === 'Paris') {
|
||||
echo "Bonjour!";
|
||||
}
|
||||
else {
|
||||
echo "Hello!";
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// Early Return statements
|
||||
// -----------------------------
|
||||
|
||||
function checkAge($age) {
|
||||
// Early return if age is less than 18
|
||||
if ($age < 18) {
|
||||
return "Too young";
|
||||
}
|
||||
// Continue with the function if age is 18+
|
||||
return "Welcome!";
|
||||
}
|
||||
|
||||
echo checkAge(16); // Outputs: Too young
|
||||
echo checkAge(20); // Outputs: Welcome!
|
||||
|
||||
// -----------------------------
|
||||
// Ternary Expressions
|
||||
// - Only good for replacing non-complex IF/ELSE statements
|
||||
// -----------------------------
|
||||
|
||||
$age = 20;
|
||||
$can_vote = ($age >= 18) ? 'Yes' : 'No'
|
||||
|
||||
// Alternatively, you could write the above like this, but the above saves lines of code.
|
||||
if ($age >= 18) {
|
||||
$can_vote = 'Yes';
|
||||
}
|
||||
else {
|
||||
$can_vote = 'No';
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// Switch statements
|
||||
// -----------------------------
|
||||
|
||||
// E.g.
|
||||
switch ($isOlympicYear) {
|
||||
case 2023:
|
||||
break; // Without a break, the code will continue executing to the next case.
|
||||
|
||||
case 2024:
|
||||
break;
|
||||
|
||||
case 2025:
|
||||
break;
|
||||
|
||||
default: // Default is the equivalent to an ELSE
|
||||
break;
|
||||
}
|
||||
|
||||
// Using a switch like above instead of the following
|
||||
if ($year === 2023) {
|
||||
//
|
||||
}
|
||||
elseif ($year === 2024) {
|
||||
//
|
||||
}
|
||||
elseif ($year === 2025) {
|
||||
//
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// For loops
|
||||
// -----------------------------
|
||||
|
||||
// E.g.
|
||||
for ($i = 1; $i < 5; $i++) {
|
||||
echo "This is the $i -th iteration.";
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// While loops
|
||||
// -----------------------------
|
||||
|
||||
// E.g.
|
||||
$i = 1;
|
||||
while ($i < 5) {
|
||||
echo "This is the $i -th iteration.";
|
||||
$i++;
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// Passing Arguments by Reference
|
||||
// -----------------------------
|
||||
|
||||
function add_five(&$value) {
|
||||
$value += 5;
|
||||
}
|
||||
|
||||
$num = 2;
|
||||
add_five($num);
|
||||
echo $num; // Outputs: 7
|
||||
|
||||
// -----------------------------
|
||||
// Using the ... operator
|
||||
// - Allows for any number of arguments
|
||||
// -----------------------------
|
||||
|
||||
function sum(...$numbers) {
|
||||
$sum = 0;
|
||||
|
||||
for ($i = 0; $i < count($numbers); $i++) {
|
||||
$sum += $numbers[$i];
|
||||
}
|
||||
|
||||
return $sum;
|
||||
}
|
||||
|
||||
echo sum(1, 2, 3, 4); // Output: 10
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
/* Arrays */
|
||||
|
||||
$months = array(
|
||||
'January', // Index = 0
|
||||
'February', // Index = 1
|
||||
'March', // Index = 2
|
||||
);
|
||||
echo '<pre>';
|
||||
print_r($months);
|
||||
echo '</pre>';
|
||||
|
||||
// Getting value from index
|
||||
echo '<pre>';
|
||||
print_r($months[1]);
|
||||
echo '</pre>';
|
||||
|
||||
// Short hand
|
||||
$months = [
|
||||
'January', // Index = 0
|
||||
'February', // Index = 1
|
||||
'March', // Index = 2
|
||||
];
|
||||
|
||||
/* Associative Arrays */
|
||||
|
||||
$months = [
|
||||
'month1' => 'January',
|
||||
'month2' => 'February',
|
||||
'month3' => 'March'
|
||||
];
|
||||
echo '<pre>';
|
||||
print_r($months);
|
||||
echo '</pre>';
|
||||
echo '<pre>';
|
||||
print_r($months['month1']);
|
||||
echo '</pre>';
|
||||
|
||||
/* Working with Arrays */
|
||||
|
||||
// range()
|
||||
$numbers = range(1, 10); // Same as $numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
echo '<pre>';
|
||||
print_r($numbers);
|
||||
echo '</pre>';
|
||||
|
||||
$numbers = range(1, 10, 2); // Same as $numbers = [1, 3, 5, 7, 9];
|
||||
echo '<pre>';
|
||||
print_r($numbers);
|
||||
echo '</pre>';
|
||||
|
||||
// Adding to arrays
|
||||
$months = [
|
||||
'January', // Index = 0
|
||||
'February', // Index = 1
|
||||
'March', // Index = 2
|
||||
];
|
||||
// Add to index 3
|
||||
$months[3] = 'April';
|
||||
// Change index 2
|
||||
$months[2] = 'May';
|
||||
// Add to end of array
|
||||
$months[] = 'June';
|
||||
echo '<pre>';
|
||||
print_r($months);
|
||||
echo '</pre>';
|
||||
|
||||
/* Merging Arrays */
|
||||
$sem1grades = [
|
||||
'math' => 90,
|
||||
'chemistry' => 67,
|
||||
'biology' => 88,
|
||||
'history' => 45,
|
||||
'gym' => 60,
|
||||
];
|
||||
$sem2grades = [
|
||||
'philosophy' => 87,
|
||||
'art' => 99,
|
||||
'physics' => 71,
|
||||
'gym' => 60,
|
||||
];
|
||||
|
||||
// array_merge()
|
||||
$allGrades = array_merge($sem1grades, $sem2grades);
|
||||
echo '<pre>';
|
||||
print_r($allGrades);
|
||||
echo '</pre>';
|
||||
|
||||
// Array Union
|
||||
$allGrades = $sem1grades + $sem2grades;
|
||||
echo '<pre>';
|
||||
print_r($allGrades);
|
||||
echo '</pre>';
|
||||
|
||||
/* Multidimensional arrays */
|
||||
$meats = [
|
||||
'Pepperoni',
|
||||
'Bacon',
|
||||
'Ham',
|
||||
];
|
||||
$cheeses = [
|
||||
'Mozzarella',
|
||||
'Cheddar',
|
||||
'Swiss',
|
||||
];
|
||||
$veggies = [
|
||||
'Onions',
|
||||
'Peppers',
|
||||
'Mushrooms',
|
||||
];
|
||||
$toppings = [
|
||||
'Meats' => $meats,
|
||||
'Cheeses' => $cheeses,
|
||||
'Veggies' => $veggies,
|
||||
'Size' => 'Medium',
|
||||
];
|
||||
echo $toppings['Veggies'][1];
|
||||
echo '<br><br>';
|
||||
|
||||
/* Printing Arrays */
|
||||
|
||||
// foreach()
|
||||
foreach ($toppings as $type => $value) {
|
||||
echo "{$type}:</br>";
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $number => $topping) {
|
||||
echo "Topping #{$number} is $topping</br>";
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "{$type} is $value</br>";
|
||||
}
|
||||
echo "</br>";
|
||||
}
|
||||
|
||||
$words = [
|
||||
'The',
|
||||
'cow',
|
||||
'jumped',
|
||||
'over',
|
||||
'the',
|
||||
'moon',
|
||||
];
|
||||
// implode()
|
||||
$sentence = implode(' ', $words);
|
||||
echo $sentence;
|
||||
echo '<br><br>';
|
||||
// explode()
|
||||
$words2 = explode(' ', $sentence);
|
||||
echo $words2;
|
||||
echo '<br><br>';
|
||||
|
||||
/* Sorting Arrays */
|
||||
|
||||
$array1 = [
|
||||
3,
|
||||
1,
|
||||
4,
|
||||
1,
|
||||
5,
|
||||
9,
|
||||
];
|
||||
// sort()
|
||||
sort($array1);
|
||||
echo '<pre>';
|
||||
print_r($array1);
|
||||
echo '</pre>';
|
||||
// rsort()
|
||||
rsort($array1);
|
||||
echo '<pre>';
|
||||
print_r($array1);
|
||||
echo '</pre>';
|
||||
|
||||
$assocArray = [
|
||||
'a' => 3,
|
||||
'b' => 1,
|
||||
'c' => 4,
|
||||
];
|
||||
// asort()
|
||||
asort($assocArray);
|
||||
echo '<pre>';
|
||||
print_r($assocArray);
|
||||
echo '</pre>';
|
||||
$assocArray = [
|
||||
'a' => 3,
|
||||
'b' => 1,
|
||||
'c' => 4,
|
||||
];
|
||||
// ksort()
|
||||
ksort($assocArray);
|
||||
echo '<pre>';
|
||||
print_r($assocArray);
|
||||
echo '</pre>';
|
||||
@@ -0,0 +1,25 @@
|
||||
USE mynorthwind;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS invoices (
|
||||
invoiceId INT AUTO_INCREMENT PRIMARY KEY,
|
||||
customer VARCHAR(5) NOT NULL,
|
||||
amount INT NOT NULL,
|
||||
date DATE NOT NULL,
|
||||
FOREIGN KEY (customer) REFERENCES customers(CustomerID)
|
||||
);
|
||||
|
||||
INSERT INTO invoices (customer, amount, date) VALUES ('ANATR', 250, '2026-01-06');
|
||||
INSERT INTO invoices (customer, amount, date) VALUES ('ANTON', 375, '2026-01-02');
|
||||
INSERT INTO invoices (customer, amount, date) VALUES ('ALFKI', 125, '2026-01-25');
|
||||
|
||||
CREATE TABLE IF NOT EXISTS returns (
|
||||
returnId INT AUTO_INCREMENT PRIMARY KEY,
|
||||
customer VARCHAR(5) NOT NULL,
|
||||
amount INT NOT NULL,
|
||||
date DATE NOT NULL,
|
||||
FOREIGN KEY (customer) REFERENCES customers(CustomerID)
|
||||
);
|
||||
|
||||
INSERT INTO returns (customer, amount, date) VALUES ('ANATR', 111, '2026-02-12');
|
||||
INSERT INTO returns (customer, amount, date) VALUES ('ANTON', 950, '2026-02-26');
|
||||
INSERT INTO returns (customer, amount, date) VALUES ('ALFKI', 10205, '2026-03-01');
|
||||
@@ -0,0 +1,76 @@
|
||||
Customers
|
||||
ID
|
||||
First name
|
||||
Last name
|
||||
Street Address
|
||||
City
|
||||
Province/State
|
||||
Postal Code
|
||||
Phone Number
|
||||
Email Address
|
||||
|
||||
Purpose:
|
||||
Tracks who the client is and how to contact them.
|
||||
|
||||
Relationship:
|
||||
One customer can have multiple contracts.
|
||||
|
||||
Contracts
|
||||
Contract ID (unique identifier)
|
||||
Customer ID (links to the customer)
|
||||
Building Street Address
|
||||
City
|
||||
Province/State
|
||||
Postal Code
|
||||
Scheduled Date
|
||||
Scheduled Time
|
||||
Employee ID (employee assigned to the job)
|
||||
|
||||
Purpose:
|
||||
Tracks each job being performed.
|
||||
|
||||
Relationships:
|
||||
Each contract belongs to one customer.
|
||||
Each contract is handled by one employee.
|
||||
Each contract can contain multiple rooms.
|
||||
|
||||
Rooms
|
||||
Room ID
|
||||
Contract ID
|
||||
Room Name
|
||||
Paint ID
|
||||
|
||||
Purpose:
|
||||
Tracks individual areas being painted for each contract.
|
||||
|
||||
Relationships:
|
||||
Each room belongs to one contract.
|
||||
Each room uses one paint color.
|
||||
|
||||
Inventory
|
||||
Paint ID
|
||||
Paint Name
|
||||
Cost Per Can
|
||||
Quantity
|
||||
|
||||
Purpose:
|
||||
Tracks paint options and pricing so customers know how much each paint can costs.
|
||||
|
||||
Relationships:
|
||||
One paint type can be used in many rooms.
|
||||
|
||||
Employees
|
||||
Employee ID
|
||||
First Name
|
||||
Last Name
|
||||
Address
|
||||
Postal Code
|
||||
Hire Date
|
||||
Salary
|
||||
|
||||
Purpose:
|
||||
Tracks the staff doing the work.
|
||||
|
||||
Relationship:
|
||||
One employee can be assigned to multiple contracts.
|
||||
Each contract has exactly one employee.
|
||||
@@ -0,0 +1,172 @@
|
||||
CREATE DATABASE IF NOT EXISTS `paintingbusiness` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */;
|
||||
USE `paintingbusiness`;
|
||||
-- MySQL dump 10.13 Distrib 8.0.45, for Win64 (x86_64)
|
||||
--
|
||||
-- Host: 127.0.0.1 Database: paintingbusiness
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 5.5.5-10.4.32-MariaDB
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!50503 SET NAMES utf8 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `contracts`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `contracts`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `contracts` (
|
||||
`contract_id` int(11) NOT NULL,
|
||||
`customer_id` int(11) NOT NULL,
|
||||
`employee_id` int(11) NOT NULL,
|
||||
`address` varchar(255) NOT NULL,
|
||||
`scheduled_for` datetime NOT NULL,
|
||||
PRIMARY KEY (`contract_id`),
|
||||
KEY `customer_id` (`customer_id`),
|
||||
KEY `employee_id` (`employee_id`),
|
||||
CONSTRAINT `contracts_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`customer_id`),
|
||||
CONSTRAINT `contracts_ibfk_2` FOREIGN KEY (`employee_id`) REFERENCES `employees` (`employee_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `contracts`
|
||||
--
|
||||
|
||||
LOCK TABLES `contracts` WRITE;
|
||||
/*!40000 ALTER TABLE `contracts` DISABLE KEYS */;
|
||||
INSERT INTO `contracts` VALUES (1,1,2,'123 Maple St','2026-04-10 10:00:00'),(2,2,1,'45 Oak Ave','2026-04-12 09:00:00'),(3,3,3,'78 Pine Rd','2026-04-15 13:30:00');
|
||||
/*!40000 ALTER TABLE `contracts` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `customers`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `customers`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `customers` (
|
||||
`customer_id` int(11) NOT NULL,
|
||||
`first_name` varchar(25) NOT NULL,
|
||||
`last_name` varchar(30) NOT NULL,
|
||||
`address` varchar(255) NOT NULL,
|
||||
`phone` varchar(15) NOT NULL,
|
||||
`email` varchar(30) NOT NULL,
|
||||
PRIMARY KEY (`customer_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `customers`
|
||||
--
|
||||
|
||||
LOCK TABLES `customers` WRITE;
|
||||
/*!40000 ALTER TABLE `customers` DISABLE KEYS */;
|
||||
INSERT INTO `customers` VALUES (1,'John','Smith','123 Maple St','416-555-1111','john.smith@email.com'),(2,'Sarah','Johnson','45 Oak Ave','416-555-2222','sarah.j@email.com'),(3,'Michael','Brown','78 Pine Rd','416-555-3333','m.brown@email.com');
|
||||
/*!40000 ALTER TABLE `customers` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `employees`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `employees`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `employees` (
|
||||
`employee_id` int(11) NOT NULL,
|
||||
`first_name` varchar(25) NOT NULL,
|
||||
`last_name` varchar(30) NOT NULL,
|
||||
`address` varchar(255) NOT NULL,
|
||||
`hire_date` datetime NOT NULL,
|
||||
`salary` int(11) NOT NULL,
|
||||
PRIMARY KEY (`employee_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `employees`
|
||||
--
|
||||
|
||||
LOCK TABLES `employees` WRITE;
|
||||
/*!40000 ALTER TABLE `employees` DISABLE KEYS */;
|
||||
INSERT INTO `employees` VALUES (1,'David','Wilson','22 Birch Ln','2022-04-12 09:00:00',45000),(2,'Emily','Davis','91 Cedar Dr','2023-01-20 09:00:00',42000),(3,'Robert','Taylor','15 Spruce Ct','2021-07-15 09:00:00',48000);
|
||||
/*!40000 ALTER TABLE `employees` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `inventory`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `inventory`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `inventory` (
|
||||
`paint_id` int(11) NOT NULL,
|
||||
`paint_name` varchar(30) NOT NULL,
|
||||
`cost_per_can` decimal(2,0) NOT NULL,
|
||||
`quantity` int(11) NOT NULL,
|
||||
PRIMARY KEY (`paint_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `inventory`
|
||||
--
|
||||
|
||||
LOCK TABLES `inventory` WRITE;
|
||||
/*!40000 ALTER TABLE `inventory` DISABLE KEYS */;
|
||||
INSERT INTO `inventory` VALUES (1,'Arctic White',30,50),(2,'Ocean Blue',35,40),(3,'Sunset Yellow',28,60);
|
||||
/*!40000 ALTER TABLE `inventory` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `rooms`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `rooms`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `rooms` (
|
||||
`room_id` int(11) NOT NULL,
|
||||
`contract_id` int(11) NOT NULL,
|
||||
`paint_id` int(11) NOT NULL,
|
||||
`room_name` varchar(30) NOT NULL,
|
||||
PRIMARY KEY (`room_id`),
|
||||
KEY `contract_id` (`contract_id`),
|
||||
KEY `paint_id` (`paint_id`),
|
||||
CONSTRAINT `rooms_ibfk_1` FOREIGN KEY (`contract_id`) REFERENCES `contracts` (`contract_id`),
|
||||
CONSTRAINT `rooms_ibfk_2` FOREIGN KEY (`paint_id`) REFERENCES `inventory` (`paint_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `rooms`
|
||||
--
|
||||
|
||||
LOCK TABLES `rooms` WRITE;
|
||||
/*!40000 ALTER TABLE `rooms` DISABLE KEYS */;
|
||||
INSERT INTO `rooms` VALUES (1,1,1,'Living Room'),(2,2,2,'Bedroom'),(3,3,3,'Kitchen');
|
||||
/*!40000 ALTER TABLE `rooms` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2026-03-14 20:50:41
|
||||
@@ -0,0 +1,46 @@
|
||||
CREATE DATABASE IF NOT EXISTS paintingBusiness;
|
||||
USE paintingBusiness;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS customers(
|
||||
customer_id INT NOT NULL PRIMARY KEY,
|
||||
first_name VARCHAR(25) NOT NULL,
|
||||
last_name VARCHAR(30) NOT NULL,
|
||||
`address` VARCHAR(255) NOT NULL,
|
||||
phone VARCHAR(15) NOT NULL,
|
||||
email VARCHAR(30) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS employees(
|
||||
employee_id INT NOT NULL PRIMARY KEY,
|
||||
first_name VARCHAR(25) NOT NULL,
|
||||
last_name VARCHAR(30) NOT NULL,
|
||||
`address` VARCHAR(255) NOT NULL,
|
||||
hire_date DATETIME NOT NULL,
|
||||
salary INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS inventory(
|
||||
paint_id INT NOT NULL PRIMARY KEY,
|
||||
paint_name VARCHAR(30) NOT NULL,
|
||||
cost_per_can DECIMAL(5,2) NOT NULL,
|
||||
quantity INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS contracts(
|
||||
contract_id INT NOT NULL PRIMARY KEY,
|
||||
customer_id INT NOT NULL,
|
||||
employee_id INT NOT NULL,
|
||||
`address` VARCHAR(255) NOT NULL,
|
||||
scheduled_for DATETIME NOT NULL,
|
||||
FOREIGN KEY (customer_id) REFERENCES customers(customer_id),
|
||||
FOREIGN KEY (employee_id) REFERENCES employees(employee_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS rooms(
|
||||
room_id INT NOT NULL PRIMARY KEY,
|
||||
contract_id INT NOT NULL,
|
||||
paint_id INT NOT NULL,
|
||||
room_name VARCHAR(30) NOT NULL,
|
||||
FOREIGN KEY (contract_id) REFERENCES contracts(contract_id),
|
||||
FOREIGN KEY (paint_id) REFERENCES inventory(paint_id)
|
||||
);
|
||||
@@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Lab 7 Levi McLean</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<form>
|
||||
<label for="fname">First Name</label>
|
||||
<input type="text" name="fname"><br>
|
||||
<label for="lname">Last Name</label>
|
||||
<input type="text" name="lname"><br>
|
||||
<label for="email">Email</label>
|
||||
<input type="email" name="email"><br>
|
||||
<label for="password">Password</label>
|
||||
<input type="password" name="password"><br>
|
||||
<label for="address">Address</label>
|
||||
<input type="text" name="address"><br>
|
||||
<label for="city">City</label>
|
||||
<input type="text" name="city"><br>
|
||||
<label for="country">Country</label>
|
||||
<input type="text" name="country"><br>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,58 @@
|
||||
CREATE DATABASE IF NOT EXISTS `lab7` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */;
|
||||
USE `lab7`;
|
||||
-- MySQL dump 10.13 Distrib 8.0.44, for Win64 (x86_64)
|
||||
--
|
||||
-- Host: 127.0.0.1 Database: lab7
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 5.5.5-10.4.32-MariaDB
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!50503 SET NAMES utf8 */;
|
||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
||||
|
||||
--
|
||||
-- Table structure for table `registration`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `registration`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `registration` (
|
||||
`reg_id` int(11) NOT NULL,
|
||||
`fname` varchar(30) NOT NULL,
|
||||
`lname` varchar(30) NOT NULL,
|
||||
`email` varchar(100) NOT NULL,
|
||||
`password` varchar(255) NOT NULL,
|
||||
`address` varchar(255) NOT NULL,
|
||||
`city` varchar(30) NOT NULL,
|
||||
`country` varchar(30) NOT NULL,
|
||||
PRIMARY KEY (`reg_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `registration`
|
||||
--
|
||||
|
||||
LOCK TABLES `registration` WRITE;
|
||||
/*!40000 ALTER TABLE `registration` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `registration` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
||||
|
||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2026-04-01 19:11:27
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
$databaseHost = 'localhost'; // localhost
|
||||
$databaseName = 'lab7'; // your db_name
|
||||
$databaseUsername = 'root'; // root by default for localhost
|
||||
$mysqli = mysqli_connect($databaseHost, $databaseUsername, $databaseName);
|
||||
?>
|
||||
<?php
|
||||
if(isset($_POST['submit']))
|
||||
{
|
||||
$fname = $_POST['fname'];
|
||||
$lname = $_POST['lname'];
|
||||
$email = $_POST['email'];
|
||||
$password = $_POST['password'];
|
||||
$address = $_POST['address'];
|
||||
$city = $_POST['city'];
|
||||
$country = $_POST['country'];
|
||||
$result = mysqli_query($mysqli,"insert into user values('','$fname','$lname','$email','$password','$address','$city','$country')");
|
||||
if($result) {
|
||||
echo "Registration Successfully";
|
||||
}
|
||||
else {
|
||||
echo "failed:";
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Lab 7 Levi McLean</title>
|
||||
<link rel="stylesheet" href="./style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<form method="post" action="action.php">
|
||||
<label for="fname">First Name</label>
|
||||
<input type="text" name="fname"><br>
|
||||
<label for="lname">Last Name</label>
|
||||
<input type="text" name="lname"><br>
|
||||
<label for="email">Email</label>
|
||||
<input type="email" name="email"><br>
|
||||
<label for="password">Password</label>
|
||||
<input type="password" name="password"><br>
|
||||
<label for="address">Address</label>
|
||||
<input type="text" name="address"><br>
|
||||
<label for="city">City</label>
|
||||
<input type="text" name="city"><br>
|
||||
<label for="country">Country</label>
|
||||
<input type="text" name="country"><br>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,6 @@
|
||||
body {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
background-color: darkred;
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
Create and use database Rebu
|
||||
*/
|
||||
CREATE DATABASE IF NOT EXISTS Rebu;
|
||||
USE Rebu;
|
||||
|
||||
/*
|
||||
Create table for drivers
|
||||
*/
|
||||
DROP TABLE IF EXISTS drivers;
|
||||
CREATE TABLE IF NOT EXISTS drivers(
|
||||
driver_id INT NOT NULL PRIMARY KEY,
|
||||
salutation VARCHAR(3) NOT NULL,
|
||||
fname VARCHAR(30) NOT NULL,
|
||||
lname VARCHAR(30) NOT NULL,
|
||||
`address` VARCHAR(100) NOT NULL,
|
||||
phone VARCHAR(20) NOT NULL UNIQUE,
|
||||
email VARCHAR(100) NOT NULL UNIQUE,
|
||||
insurance_provider VARCHAR(30) NOT NULL,
|
||||
policy_number VARCHAR(15) NOT NULL UNIQUE,
|
||||
speeding_tickers INT,
|
||||
accidents INT
|
||||
);
|
||||
|
||||
/*
|
||||
Create table for vehicles, in case a driver has two or more
|
||||
*/
|
||||
DROP TABLE IF EXISTS vehicles;
|
||||
CREATE TABLE IF NOT EXISTS vehicles(
|
||||
vehicle_id INT NOT NULL PRIMARY KEY,
|
||||
driver_id INT NOT NULL,
|
||||
vehicle_make VARCHAR(30) NOT NULL,
|
||||
vehicle_model VARCHAR(30) NOT NULL,
|
||||
vehicle_year VARCHAR(4) NOT NULL,
|
||||
license_plate VARCHAR(7) NOT NULL,
|
||||
FOREIGN KEY (driver_id) REFERENCES drivers(driver_id)
|
||||
);
|
||||
|
||||
/*
|
||||
Create table for payment cards, in case rider has multiple
|
||||
*/
|
||||
DROP TABLE IF EXISTS cards;
|
||||
CREATE TABLE IF NOT EXISTS cards(
|
||||
card_id INT NOT NULL PRIMARY KEY,
|
||||
rider_id INT NOT NULL,
|
||||
card_number VARCHAR(12) NOT NULL,
|
||||
card_name VARCHAR(100) NOT NULL,
|
||||
card_expiry VARCHAR(12) NOT NULL,
|
||||
FOREIGN KEY (rider_id) REFERENCES riders(rider_id)
|
||||
);
|
||||
|
||||
/*
|
||||
Create table for riders
|
||||
*/
|
||||
DROP TABLE IF EXISTS riders;
|
||||
CREATE TABLE IF NOT EXISTS riders(
|
||||
rider_id INT NOT NULL PRIMARY KEY,
|
||||
`address` VARCHAR(100) NOT NULL,
|
||||
phone VARCHAR(20) NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
/*
|
||||
Create table for the actual ride information
|
||||
*/
|
||||
DROP TABLE IF EXISTS rides;
|
||||
CREATE TABLE IF NOT EXISTS rides(
|
||||
ride_id INT NOT NULL PRIMARY KEY,
|
||||
pickup_location VARCHAR(100) NOT NULL,
|
||||
pickup_date DATE NOT NULL,
|
||||
pickup_time TIME NOT NULL,
|
||||
dropoff_location VARCHAR(100) NOT NULL,
|
||||
base_cost DECIMAL(5,2) NOT NULL,
|
||||
hst DECIMAL(5,2) GENERATED ALWAYS AS (ROUND(base_cost * 0.13,2)) STORED,
|
||||
total_cost DECIMAL(5,2) GENERATED ALWAYS AS (ROUND(base_cost * 1.13,2)) STORED,
|
||||
driver_id INT NOT NULL,
|
||||
driver_satisfaction INT NOT NULL CHECK (driver_satisfaction BETWEEN 1 AND 5),
|
||||
rider_id INT NOT NULL,
|
||||
card_id INT NOT NULL,
|
||||
FOREIGN KEY (driver_id) REFERENCES drivers(driver_id),
|
||||
FOREIGN KEY (card_id) REFERENCES cards(card_id)
|
||||
);
|
||||
|
||||
/*
|
||||
Some simple select and join statements for testing and demonstration purposes
|
||||
*/
|
||||
INSERT INTO drivers VALUES
|
||||
(1, 'Mr', 'John', 'Doe', '123 Main St', '111-111-1111', 'john@example.com', 'StateFarm', 'POL123', 1, 0),
|
||||
(2, 'Ms', 'Jane', 'Smith', '456 Oak Ave', '222-222-2222', 'jane@example.com', 'Allianz', 'POL456', 0, 1),
|
||||
(3, 'Mr', 'Mike', 'Brown', '789 Pine Rd', '333-333-3333', 'mike@example.com', 'Geico', 'POL789', 2, 2);
|
||||
|
||||
INSERT INTO vehicles VALUES
|
||||
(1, 1, 'Toyota', 'Camry', '2020', 'ABC1234'),
|
||||
(2, 2, 'Honda', 'Civic', '2019', 'XYZ5678'),
|
||||
(3, 3, 'Ford', 'Focus', '2018', 'LMN9101');
|
||||
|
||||
INSERT INTO riders VALUES
|
||||
(1, '12 King St', '444-444-4444'),
|
||||
(2, '34 Queen St', '555-555-5555'),
|
||||
(3, '56 Prince St', '666-666-6666');
|
||||
|
||||
INSERT INTO cards VALUES
|
||||
(1, 1, '123456789012', 'John Doe', '12/27'),
|
||||
(2, 2, '234567890123', 'Jane Smith', '11/26'),
|
||||
(3, 3, '345678901234', 'Mike Brown', '10/25');
|
||||
|
||||
INSERT INTO rides (ride_id, pickup_location, pickup_date, pickup_time, dropoff_location, base_cost, driver_id, driver_satisfaction, card_id, rider_id) VALUES
|
||||
(1, 'Downtown', '2026-03-01', '08:00:00', 'Airport', 20.00, 1, 5, 1, 1),
|
||||
(2, 'Mall', '2026-03-02', '09:30:00', 'University', 15.50, 2, 4, 2, 2),
|
||||
(3, 'Station', '2026-03-03', '11:00:00', 'Hotel', 30.00, 3, 3, 3, 3);
|
||||
|
||||
SELECT * FROM drivers;
|
||||
SELECT * FROM vehicles;
|
||||
SELECT * FROM riders;
|
||||
SELECT * FROM cards;
|
||||
SELECT * FROM rides;
|
||||
|
||||
SELECT * FROM drivers
|
||||
INNER JOIN vehicles ON drivers.driver_id = vehicles.driver_id;
|
||||
|
||||
SELECT * FROM riders
|
||||
INNER JOIN cards ON riders.rider_id = cards.rider_id;
|
||||
|
||||
SELECT * FROM rides
|
||||
INNER JOIN drivers ON rides.driver_id = drivers.driver_id
|
||||
INNER JOIN riders ON rides.rider_id = riders.rider_id;
|
||||
|
After Width: | Height: | Size: 188 KiB |
|
After Width: | Height: | Size: 165 KiB |
|
After Width: | Height: | Size: 142 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 564 KiB |
|
After Width: | Height: | Size: 84 KiB |
|
After Width: | Height: | Size: 504 KiB |
|
After Width: | Height: | Size: 505 KiB |
|
After Width: | Height: | Size: 260 KiB |
|
After Width: | Height: | Size: 146 KiB |
|
After Width: | Height: | Size: 103 KiB |
|
After Width: | Height: | Size: 131 KiB |
|
After Width: | Height: | Size: 88 KiB |
|
After Width: | Height: | Size: 62 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 312 KiB |
|
After Width: | Height: | Size: 434 KiB |
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 93 KiB |