This repository has been archived by the owner on Sep 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add all files. After several weeks of classwork on development, commi…
…t everything. Learnging PHP files are in the PHP folder and consist of various exercises. The root contains the pool maintenance CRUD app in very good initial working order. Now moving on to javascript.
- Loading branch information
0 parents
commit 086a152
Showing
15 changed files
with
1,169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
require_once "model.php"; | ||
|
||
#function login_filter() { | ||
# if ( !isset($_SESSION["account"])) { | ||
# # | ||
# # session is set during login to indicate we are logged in lol | ||
# # | ||
# header('Location: login.php'); | ||
# } | ||
#} | ||
|
||
function controller() { | ||
# | ||
# READ a reading | ||
# | ||
if (isset($_GET['id'])) { | ||
# | ||
# typical view object path (GET) | ||
# | ||
$id = $_GET['id']; | ||
reading_read_model($id); | ||
#model code | ||
#...drop through to HTML | ||
} else if (isset($_SESSION['reading_index'])) { | ||
# | ||
# specail cases to dispaly while performing some other action | ||
# then the id is stored in session, but we are still going to display it | ||
# | ||
$id = $_SESSION['reading_index']; | ||
reading_read_model($id); | ||
#model code | ||
#...drop through to HTML | ||
} | ||
|
||
# | ||
# vector: create button isset via POST | ||
# controler: create object | ||
# model: object: reading, action: create | ||
# view: redirect GET[id] to 'manage object' page. | ||
# | ||
if (isset($_POST['reading_create'])) { | ||
# model | ||
$new_id = reading_create_model(); | ||
# view | ||
header("Location: manage_reading.php?id=$new_id"); | ||
} | ||
|
||
# | ||
# vector: update button isset via POST | ||
# data: object values by $k in POST | ||
# controller: update object | ||
# model: object is 'reading', action is 'update' | ||
# view: redirect GET[id] to 'manage object' page | ||
# | ||
if (isset($_POST['reading_update'])) { | ||
# model code | ||
reading_update_model(); | ||
# view code | ||
$id = $_POST['reading_index']; | ||
header("Location: manage_reading.php?id=$id"); | ||
} | ||
|
||
if (isset($_POST['reading_delete'])) { | ||
# model code - session indicator to show confirm behavior | ||
$_SESSION['reading_delete'] = $_POST['reading_delete']; | ||
$_SESSION['reading_index'] = $_POST['reading_index']; | ||
# view code | ||
session_write_close(); | ||
header("Location: manage_reading.php"); | ||
} | ||
|
||
# | ||
# vector: affirm delete button via POST | ||
# data: reading_index from POST | ||
# controller: delete object | ||
# model: object is 'reading", action is 'delete' | ||
# view: redirect/GET to index | ||
# | ||
if (isset($_POST['confirm_delete'])) { | ||
# model code | ||
reading_delete_model(); | ||
# view code | ||
header("Location: index.php"); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
session_start(); | ||
require_once "utils.php"; | ||
require_once "controller.php"; | ||
#login_filter(); | ||
controller(); | ||
#print_post_get_session(); | ||
?> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title> Pool Water Management </title> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1 class="sticky-top bg-white"> Pool Water Management </h1> | ||
</div> | ||
<!-- Alert / flash message handling --> | ||
<?php process_alerts() ?> | ||
<!-- main View code for Index page --> | ||
<div class="container"> | ||
<form method="post", action="\manage_reading.php"> | ||
<table class='table table-hover'> | ||
<thead> | ||
<tr> | ||
<th> Number </th> | ||
<th> Collection Date </th> | ||
<th> Collection Time </th> | ||
<th> Chlorine PPM </th> | ||
<th> PH Level </th> | ||
<th> Alkalinity ppm </th> | ||
<th> Cyanuric Acid ppm </th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<?php | ||
$pdo = db_connect(); | ||
foreach($pdo->query('SELECT * from chemicals_reading') as $row) { | ||
# | ||
# foreach iterates across readings pulling each one as $row assoc array. | ||
# then iterate over the array using foreach a second time to get at values | ||
#print_r($row); | ||
# | ||
echo "<tr>"; | ||
foreach($row as $k => $v) { | ||
if ($k == 'reading_index') { | ||
echo "<td>"; | ||
echo "<a href='\manage_reading.php?id=$v'> $v </a>"; | ||
echo "</td>"; | ||
} else { | ||
echo "<td> $v </td>"; | ||
} | ||
} | ||
echo "</tr>"; | ||
} | ||
$pdo = null; | ||
?> | ||
</tbody> | ||
</table> | ||
<br> | ||
<!-- Buttons to add an entry ---> | ||
<button name="add_reading" class='btn btn-dark btn-lg' id='add_reading_id'>Add Reading</button> | ||
</form> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
function bill_your_text(string &$bill_string) { | ||
$bill_string = $bill_string . "Bill!"; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}"> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> | ||
|
||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1 class="sticky-top bg-white"> PHP Form Samples </h1> | ||
</div> | ||
|
||
<form> | ||
<p> | ||
<label for="num">Sample Number field/label> | ||
<input type="number" name="sample_number" size="40", id="num", value="451"/> | ||
<br> | ||
<label for="texty">Sample text field</label> | ||
<input type="text" name="sample_text" size="40" id="texy" value="Sample McSample Text"/> | ||
<br> | ||
<label for="pw">Sample password field</label> | ||
<input type="password" name="sample_password" size="40" id="pw" value="Pooping sound from Camel"/> | ||
<br> | ||
<p>Sample Radio Button:<br></p> | ||
<input type="radio" name="sample_radio" value="Beef" checked> Big Beefy<br> | ||
<input type="radio" name="sample_radio" value="Chicken"> Chicken<br> | ||
<input type="radio" name="sample_radio" value="Pork"> Porky Pig<br> | ||
<br> | ||
<p>Sample checkbox:<br></p> | ||
<input type="checkbox" name="sample_checkbox1" value="Carnitas" checked>Mas Carnitas<br> | ||
<input type="checkbox" name="sample_checkbox2" value="Pollo Asado" >Pollo Asado<br> | ||
<input type="checkbox" name="sample_checkbox3" value="Lengua">Lengua<br> | ||
<input type="checkbox" name="sample_checkbox4" value="Cabesa">Cabesa Ooooo<br> | ||
|
||
|
||
<input type="submit"/> | ||
</p> | ||
</form> | ||
|
||
<pre> | ||
<?php | ||
echo "<br>Test some field types and print GET/POST values<br>" | ||
echo "<br>Printing Post Data: <br>"; | ||
print_r($_POST); | ||
echo "<br>Printing Get Data: <br>"; | ||
print_r($_GET); | ||
$my_pw = $_GET['sample_password']; | ||
echo "The pw is $my_pw <br>"; | ||
#<?php echo isset($_GET["Lia_Toy"]) ? $_GET("guess") : "" | ||
?> | ||
</pre> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.