├── 10 ├── calculator1.php ├── calculator2.php ├── menus.php ├── sticky1.php └── sticky2.php ├── 11 ├── add_quote.php ├── list_dir.php ├── login.php ├── register.php ├── script_11_02 │ └── add_quote.php ├── upload_file.php ├── users.txt └── view_quote.php ├── 12 ├── add_entry.php ├── create_table.php ├── delete_entry.php ├── edit_entry.php ├── mysqli_connect.php ├── script_12_02 │ └── mysqli_connect.php ├── script_12_05 │ └── add_entry.php └── view_entries.php ├── 13 ├── htdocs │ ├── add_quote.php │ ├── css │ │ └── style.css │ ├── delete_quote.php │ ├── edit_quote.php │ ├── includes │ │ └── functions.php │ ├── index.php │ ├── login.php │ ├── logout.php │ ├── templates │ │ ├── footer.html │ │ └── header.html │ └── view_quotes.php └── mysqli_connect.php ├── 01 ├── hello1.php ├── hello2.php ├── hello3.php ├── phpinfo.php └── welcome.html ├── 02 ├── predefined.php ├── quotes.php ├── script_02_02.php └── variables.php ├── 03 ├── feedback.html ├── handle_form.php ├── hello.html ├── hello.php ├── script_03_02 │ └── feedback.html ├── script_03_04 │ └── handle_form.php └── script_03_05 │ └── handle_form.php ├── 04 ├── calculator.html ├── handle_calc.php ├── random.php ├── script_04_03 │ └── handle_calc.php ├── script_04_04 │ └── handle_calc.php └── script_04_05 │ └── handle_calc.php ├── 05 ├── handle_post.php ├── posting.html ├── script_05_03 │ └── handle_post.php ├── script_05_04 │ └── handle_post.php ├── script_05_05 │ └── handle_post.php ├── script_05_06 │ └── handle_post.php ├── script_05_07 │ └── handle_post.php └── thanks.php ├── 06 ├── handle_reg.php ├── register.html ├── register.php ├── script_06_03 │ └── handle_reg.php ├── script_06_04 │ └── handle_reg.php ├── script_06_05 │ └── handle_reg.php ├── script_06_06 │ └── handle_reg.php ├── script_06_07 │ └── handle_reg.php └── script_06_08 │ └── handle_reg.php ├── 07 ├── books.php ├── event.html ├── event.php ├── list.html ├── list.php ├── sort.php ├── soups1.php ├── soups2.php └── soups3.php ├── 08 ├── books.php ├── css │ ├── concise.min.css │ └── masthead.css ├── index.php ├── login.php ├── register.php ├── script_08_10 │ └── register.php ├── script_08_13 │ └── login.php ├── template.html ├── templates │ ├── footer.html │ ├── header.html │ ├── script_08_06 │ │ └── header.html │ ├── script_08_07 │ │ └── footer.html │ ├── script_08_11 │ │ └── header.html │ └── script_08_12 │ │ └── footer.html └── welcome.php ├── 09 ├── customize.php ├── login.php ├── logout.php ├── reset.php ├── script_09_03 │ └── customize.php ├── script_09_05.txt ├── view_settings.php └── welcome.php ├── README.md └── license.txt /01/hello1.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello, World! 6 | 7 | 8 |

The following was created by PHP: 9 | 12 |

13 | 14 | -------------------------------------------------------------------------------- /01/hello2.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello, World! 6 | 11 | 12 | 13 |

The following was created by PHP: 14 | Hello, world!"; 16 | ?> 17 |

18 | 19 | -------------------------------------------------------------------------------- /01/hello3.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello, World! 6 | 11 | 12 | 13 |

The following was created by PHP:
14 | Hello, world!"; 22 | 23 | ?> 24 | 25 |

26 | 27 | -------------------------------------------------------------------------------- /01/phpinfo.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /01/welcome.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Welcome to this Page! 6 | 7 | 8 |

This is a basic HTML page!

9 |
10 |

Even with some decoration, it's still not very exciting.

11 | 12 | -------------------------------------------------------------------------------- /02/predefined.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Predefined Variables 6 | 7 | 8 |
 9 | 
15 | 
16 | 17 | -------------------------------------------------------------------------------- /02/quotes.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Quotes 6 | 7 | 8 | Double Quotes 20 |

name1 is $name1
21 | name2 is $name2

"; 22 | 23 | print '

Single Quotes

24 |

name1 is $name1
25 | name2 is $name2

'; 26 | 27 | ?> 28 | 29 | -------------------------------------------------------------------------------- /02/script_02_02.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Variables and Comments 6 | 7 | 8 | 19 | 20 | -------------------------------------------------------------------------------- /02/variables.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Variables 6 | 7 | 8 | The address is:
$street
$city $state $zip

"; 18 | 19 | ?> 20 | 21 | -------------------------------------------------------------------------------- /03/feedback.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Feedback Form 6 | 7 | 8 | 9 |

Please complete this form to submit your feedback:

10 | 11 |
12 | 13 |

Name:

18 | 19 |

Email Address:

20 | 21 |

Response: This is... 22 | excellent 23 | okay 24 | boring

25 | 26 |

Comments:

27 | 28 | 29 | 30 |
31 |
32 | 33 | -------------------------------------------------------------------------------- /03/handle_form.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Your Feedback 6 | 7 | 8 | Thank you, $title $name, for your comments.

21 |

You stated that you found this example to be '$response' and added:
$comments

"; 22 | 23 | ?> 24 | 25 | -------------------------------------------------------------------------------- /03/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Greetings! 6 | 7 | 8 | 9 |

Click a link to say hello:

10 | 11 | 17 | 18 |
19 | 20 | -------------------------------------------------------------------------------- /03/hello.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Greetings! 6 | 11 | 12 | 13 | Hello, $name!

"; 23 | 24 | ?> 25 | 26 | -------------------------------------------------------------------------------- /03/script_03_02/feedback.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Feedback Form 6 | 7 | 8 | 9 |

Please complete this form to submit your feedback:

10 | 11 |
12 | 13 |

Name:

18 | 19 |

Email Address:

20 | 21 |

Response: This is... 22 | excellent 23 | okay 24 | boring

25 | 26 |

Comments:

27 | 28 | 29 | 30 |
31 |
32 | 33 | -------------------------------------------------------------------------------- /03/script_03_04/handle_form.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Your Feedback 6 | 7 | 8 | Thank you, $title $name, for your comments.

23 |

You stated that you found this example to be '$response' and added:
$comments

"; 24 | 25 | ?> 26 | 27 | -------------------------------------------------------------------------------- /03/script_03_05/handle_form.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Your Feedback 6 | 7 | 8 | Thank you, $title $name, for your comments.

24 |

You stated that you found this example to be '$response' and added:
$comments

"; 25 | 26 | ?> 27 | 28 | -------------------------------------------------------------------------------- /04/calculator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Product Cost Calculator 6 | 7 | 8 |

Fill out this form to calculate the total cost:

9 | 10 |
11 | 12 |

Price:

13 | 14 |

Quantity:

15 | 16 |

Discount:

17 | 18 |

Tax: (%)

19 | 20 |

Shipping method:

25 | 26 |

Number of payments to make:

27 | 28 | 29 | 30 |
31 | 32 |
33 | 34 | -------------------------------------------------------------------------------- /04/handle_calc.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Product Cost Calculator 6 | 9 | 10 | 11 | You have selected to purchase:
42 | $quantity widget(s) at
43 | $$price price each plus a
44 | $$shipping shipping cost and a
45 | $tax percent tax rate.
46 | After your $$discount discount, the total cost is 47 | $$total.
48 | Divided over $payments monthly payments, that would be $$monthly each.

"; 49 | 50 | ?> 51 | 52 | -------------------------------------------------------------------------------- /04/random.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Lucky Numbers 6 | 7 | 8 | Your lucky numbers are:
20 | $n1
21 | $n2
22 | $n3

"; 23 | 24 | ?> 25 | 26 | -------------------------------------------------------------------------------- /04/script_04_03/handle_calc.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Product Cost Calculator 6 | 9 | 10 | 11 | You have selected to purchase:
46 | $quantity widget(s) at
47 | $$price price each plus a
48 | $$shipping shipping cost and a
49 | $tax percent tax rate.
50 | After your $$discount discount, the total cost is 51 | $$total.
52 | Divided over $payments monthly payments, that would be $$monthly each.

"; 53 | 54 | ?> 55 | 56 | -------------------------------------------------------------------------------- /04/script_04_04/handle_calc.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Product Cost Calculator 6 | 9 | 10 | 11 | You have selected to purchase:
43 | $quantity widget(s) at
44 | $$price price each plus a
45 | $$shipping shipping cost and a
46 | $tax percent tax rate.
47 | After your $$discount discount, the total cost is 48 | $$total.
49 | Divided over $payments monthly payments, that would be $$monthly each.

"; 50 | 51 | ?> 52 | 53 | -------------------------------------------------------------------------------- /04/script_04_05/handle_calc.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Product Cost Calculator 6 | 9 | 10 | 11 | You have selected to purchase:
44 | $quantity widget(s) at
45 | $$price price each plus a
46 | $$shipping shipping cost and a
47 | $tax percent tax rate.
48 | After your $$discount discount, the total cost is 49 | $$total.
50 | Divided over $payments monthly payments, that would be $$monthly each.

"; 51 | 52 | ?> 53 | 54 | -------------------------------------------------------------------------------- /05/handle_post.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Forum Posting 6 | 7 | 8 | Thank you, $name, for your posting: 24 |

$posting

"; 25 | 26 | ?> 27 | 28 | -------------------------------------------------------------------------------- /05/posting.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Forum Posting 6 | 7 | 8 | 9 |

Please complete this form to submit your posting:

10 | 11 |
12 | 13 |

First Name:

14 | 15 |

Last Name:

16 | 17 |

Email Address:

18 | 19 |

Posting:

20 | 21 | 22 | 23 |
24 |
25 | 26 | -------------------------------------------------------------------------------- /05/script_05_03/handle_post.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Forum Posting 6 | 7 | 8 | Thank you, $name, for your posting: 24 |

$posting

"; 25 | 26 | ?> 27 | 28 | -------------------------------------------------------------------------------- /05/script_05_04/handle_post.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Forum Posting 6 | 7 | 8 | Thank you, $name, for your posting: 28 |

Original: $posting

29 |

Entity: $html_post

30 |

Stripped: $strip_post

"; 31 | 32 | ?> 33 | 34 | -------------------------------------------------------------------------------- /05/script_05_05/handle_post.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Forum Posting 6 | 7 | 8 | Thank you, $name, for your posting: 24 |

$posting

"; 25 | 26 | // Make a link to another page: 27 | $name = urlencode($name); 28 | $email = urlencode($_POST['email']); 29 | print "

Click here to continue.

"; 30 | 31 | ?> 32 | 33 | -------------------------------------------------------------------------------- /05/script_05_06/handle_post.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Forum Posting 6 | 7 | 8 | Thank you, $name, for your posting: 30 |

$posting...

31 |

($words words)

"; 32 | 33 | ?> 34 | 35 | -------------------------------------------------------------------------------- /05/script_05_07/handle_post.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Forum Posting 6 | 7 | 8 | Thank you, $name, for your posting: 31 |

$posting

32 |

($words words)

"; 33 | 34 | ?> 35 | 36 | -------------------------------------------------------------------------------- /05/thanks.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Thanks! 6 | 7 | 8 | Thank you, $name. We will contact you at $email.

"; 21 | 22 | ?> 23 | 24 | -------------------------------------------------------------------------------- /06/handle_reg.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Registration 6 | 7 | 8 |

Registration Results

9 | You have been successfully registered (but not really).

'; 21 | } 22 | ?> 23 | 24 | -------------------------------------------------------------------------------- /06/register.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Registration Form 6 | 7 | 8 | 9 |

Please complete this form to register:

10 | 11 |
12 | 13 |

Email Address:

14 | 15 |

Password:

16 | 17 |

Confirm Password:

18 | 19 |

Year You Were Born:

20 | 21 |

Favorite Color: 22 |

29 | 30 |

I agree to the terms (whatever they may be).

31 | 32 | 33 | 34 |
35 | 36 |
37 | 38 | -------------------------------------------------------------------------------- /06/register.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Registration Form 6 | 7 | 8 | 9 |

Please complete this form to register:

10 | 11 |
12 | 13 |

Email Address:

14 | 15 |

Password:

16 | 17 |

Confirm Password:

18 | 19 |

Date Of Birth: 20 | 35 | 43 |

44 | 45 |

Favorite Color: 46 |

53 | 54 |

I agree to the terms (whatever they may be).

55 | 56 | 57 | 58 |
59 | 60 |
61 | 62 | -------------------------------------------------------------------------------- /06/script_06_03/handle_reg.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Registration 6 | 9 | 10 | 11 |

Registration Results

12 | Please enter your email address.

'; 24 | $okay = false; 25 | } 26 | 27 | // Validate the password: 28 | if (empty($_POST['password'])) { 29 | print '

Please enter your password.

'; 30 | $okay = false; 31 | } 32 | 33 | // If there were no errors, print a success message: 34 | if ($okay) { 35 | print '

You have been successfully registered (but not really).

'; 36 | } 37 | ?> 38 | 39 | -------------------------------------------------------------------------------- /06/script_06_04/handle_reg.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Registration 6 | 9 | 10 | 11 |

Registration Results

12 | Please enter your email address.

'; 24 | $okay = false; 25 | } 26 | 27 | // Validate the password: 28 | if (empty($_POST['password'])) { 29 | print '

Please enter your password.

'; 30 | $okay = false; 31 | } 32 | 33 | // Validate the birth year: 34 | if (is_numeric($_POST['year'])) { 35 | $age = 2016 - $_POST['year']; // Calculate age this year. 36 | } else { 37 | print '

Please enter the year you were born as four digits.

'; 38 | $okay = false; 39 | } 40 | 41 | // If there were no errors, print a success message: 42 | if ($okay) { 43 | print '

You have been successfully registered (but not really).

'; 44 | print "

You will turn $age this year.

"; 45 | } 46 | ?> 47 | 48 | -------------------------------------------------------------------------------- /06/script_06_05/handle_reg.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Registration 6 | 9 | 10 | 11 |

Registration Results

12 | Please enter your email address.

'; 24 | $okay = false; 25 | } 26 | 27 | // Validate the password: 28 | if (empty($_POST['password'])) { 29 | print '

Please enter your password.

'; 30 | $okay = false; 31 | } 32 | 33 | // Check the two passwords for equality: 34 | if ($_POST['password'] != $_POST['confirm']) { 35 | print '

Your confirmed password does not match the original password.

'; 36 | $okay = false; 37 | } 38 | 39 | // Validate the birth year: 40 | if (is_numeric($_POST['year'])) { 41 | $age = 2016 - $_POST['year']; // Calculate age this year. 42 | } else { 43 | print '

Please enter the year you were born as four digits.

'; 44 | $okay = false; 45 | } 46 | 47 | // Check that they were born before this year: 48 | if ($_POST['year'] >= 2016) { 49 | print '

Either you entered your birth year wrong or you come from the future!

'; 50 | $okay = false; 51 | } 52 | 53 | // If there were no errors, print a success message: 54 | if ($okay) { 55 | print '

You have been successfully registered (but not really).

'; 56 | print "

You will turn $age this year.

"; 57 | } 58 | 59 | ?> 60 | 61 | -------------------------------------------------------------------------------- /06/script_06_06/handle_reg.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Registration 7 | 10 | 11 | 12 |

Registration Results

13 | Please enter your email address.

'; 25 | $okay = false; 26 | } 27 | 28 | // Validate the password: 29 | if (empty($_POST['password'])) { 30 | print '

Please enter your password.

'; 31 | $okay = false; 32 | } 33 | 34 | // Check the two passwords for equality: 35 | if ($_POST['password'] != $_POST['confirm']) { 36 | print '

Your confirmed password does not match the original password.

'; 37 | $okay = false; 38 | } 39 | 40 | // Validate the year: 41 | if ( is_numeric($_POST['year']) AND (strlen($_POST['year']) == 4) ) { 42 | 43 | // Check that they were born before 2016. 44 | if ($_POST['year'] < 2016) { 45 | $age = 2016 - $_POST['year']; // Calculate age this year. 46 | } else { 47 | print '

Either you entered your birth year wrong or you come from the future!

'; 48 | $okay = false; 49 | } // End of 2nd conditional. 50 | 51 | } else { // Else for 1st conditional. 52 | 53 | print '

Please enter the year you were born as four digits.

'; 54 | $okay = false; 55 | 56 | } // End of 1st conditional. 57 | 58 | // Validate the terms: 59 | if ( !isset($_POST['terms'])) { 60 | print '

You must accept the terms.

'; 61 | $okay = false; 62 | } 63 | 64 | // If there were no errors, print a success message: 65 | if ($okay) { 66 | print '

You have been successfully registered (but not really).

'; 67 | print "

You will turn $age this year.

"; 68 | } 69 | ?> 70 | 71 | -------------------------------------------------------------------------------- /06/script_06_07/handle_reg.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Registration 6 | 9 | 10 | 11 |

Registration Results

12 | Please enter your email address.

'; 24 | $okay = false; 25 | } 26 | 27 | // Validate the password: 28 | if (empty($_POST['password'])) { 29 | print '

Please enter your password.

'; 30 | $okay = false; 31 | } 32 | 33 | // Check the two passwords for equality: 34 | if ($_POST['password'] != $_POST['confirm']) { 35 | print '

Your confirmed password does not match the original password.

'; 36 | $okay = false; 37 | } 38 | 39 | // Validate the year: 40 | if ( is_numeric($_POST['year']) AND (strlen($_POST['year']) == 4) ) { 41 | 42 | // Check that they were born before 2016. 43 | if ($_POST['year'] < 2016) { 44 | $age = 2016 - $_POST['year']; // Calculate age this year. 45 | } else { 46 | print '

Either you entered your birth year wrong or you come from the future!

'; 47 | $okay = false; 48 | } // End of 2nd conditional. 49 | 50 | } else { // Else for 1st conditional. 51 | 52 | print '

Please enter the year you were born as four digits.

'; 53 | $okay = false; 54 | 55 | } // End of 1st conditional. 56 | 57 | // Validate the terms: 58 | if ( !isset($_POST['terms'])) { 59 | print '

You must accept the terms.

'; 60 | $okay = false; 61 | } 62 | 63 | // Validate the color: 64 | if ($_POST['color'] == 'red') { 65 | $color_type = 'primary'; 66 | } elseif ($_POST['color'] == 'yellow') { 67 | $color_type = 'primary'; 68 | } elseif ($_POST['color'] == 'green') { 69 | $color_type = 'secondary'; 70 | } elseif ($_POST['color'] == 'blue') { 71 | $color_type = 'primary'; 72 | } else { // Problem! 73 | print '

Please select your favorite color.

'; 74 | $okay = false; 75 | } 76 | 77 | // If there were no errors, print a success message: 78 | if ($okay) { 79 | print '

You have been successfully registered (but not really).

'; 80 | print "

You will turn $age this year.

"; 81 | print "

Your favorite color is a $color_type color.

"; 82 | } 83 | ?> 84 | 85 | -------------------------------------------------------------------------------- /06/script_06_08/handle_reg.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Registration 6 | 9 | 10 | 11 |

Registration Results

12 | Please enter your email address.

'; 24 | $okay = false; 25 | } 26 | 27 | // Validate the password: 28 | if (empty($_POST['password'])) { 29 | print '

Please enter your password.

'; 30 | $okay = false; 31 | } 32 | 33 | // Check the two passwords for equality: 34 | if ($_POST['password'] != $_POST['confirm']) { 35 | print '

Your confirmed password does not match the original password.

'; 36 | $okay = false; 37 | } 38 | 39 | // Validate the year: 40 | if ( is_numeric($_POST['year']) AND (strlen($_POST['year']) == 4) ) { 41 | 42 | // Check that they were born before 2016. 43 | if ($_POST['year'] < 2016) { 44 | $age = 2016 - $_POST['year']; // Calculate age this year. 45 | } else { 46 | print '

Either you entered your birth year wrong or you come from the future!

'; 47 | $okay = false; 48 | } // End of 2nd conditional. 49 | 50 | } else { // Else for 1st conditional. 51 | 52 | print '

Please enter the year you were born as four digits.

'; 53 | $okay = false; 54 | 55 | } // End of 1st conditional. 56 | 57 | // Validate the terms: 58 | if ( !isset($_POST['terms'])) { 59 | print '

You must accept the terms.

'; 60 | $okay = false; 61 | } 62 | 63 | // Validate the color: 64 | switch ($_POST['color']) { 65 | case 'red': 66 | $color_type = 'primary'; 67 | break; 68 | case 'yellow': 69 | $color_type = 'primary'; 70 | break; 71 | case 'green': 72 | $color_type = 'secondary'; 73 | break; 74 | case 'blue': 75 | $color_type = 'primary'; 76 | break; 77 | default: 78 | print '

Please select your favorite color.

'; 79 | $okay = false; 80 | break; 81 | } // End of switch. 82 | 83 | // If there were no errors, print a success message: 84 | if ($okay) { 85 | print '

You have been successfully registered (but not really).

'; 86 | print "

You will turn $age this year.

"; 87 | print "

Your favorite color is a $color_type color.

"; 88 | } 89 | ?> 90 | 91 | -------------------------------------------------------------------------------- /07/books.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Larry Ullman's Books and Chapters 6 | 7 | 8 |

Some of Larry Ullman's Books

9 | 'Getting Started with PHP', 'Variables', 'HTML Forms and PHP', 'Using Numbers']; 15 | 16 | // Create the second array: 17 | $phpadv = [1 => 'Advanced PHP Techniques', 'Developing Web Applications', 'Advanced Database Concepts', 'Basic Object-Oriented Programming']; 18 | 19 | // Create the third array: 20 | $phpmysql = [1 => 'Introduction to PHP', 'Programming with PHP', 'Creating Dynamic Web Sites', 'Introduction to MySQL']; 21 | 22 | // Create the multidimensional array: 23 | $books = [ 24 | 'PHP VQS' => $phpvqs, 25 | 'PHP Advanced VQP' => $phpadv, 26 | 'PHP and MySQL VQP' => $phpmysql 27 | ]; 28 | 29 | // Print out some values: 30 | print "

The third chapter of my first book is {$books['PHP VQS'][3]}.

"; 31 | print "

The first chapter of my second book is {$books['PHP Advanced VQP'][1]}.

"; 32 | print "

The fourth chapter of my fourth book is {$books['PHP and MySQL VQP'][4]}.

"; 33 | 34 | // See what happens with foreach: 35 | foreach ($books as $key => $value) { 36 | print "

$key: $value

\n"; 37 | } 38 | 39 | ?> 40 | 41 | -------------------------------------------------------------------------------- /07/event.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Add an Event 6 | 7 | 8 | 9 |

Use this form to add an event:

10 | 11 |
12 | 13 |

Event Name:

14 |

Event Days: 15 | Sun 16 | Mon 17 | Tue 18 | Wed 19 | Thu 20 | Fri 21 | Sat 22 |

23 | 24 | 25 |
26 |
27 | 28 | -------------------------------------------------------------------------------- /07/event.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Add an Event 6 | 7 | 8 | You want to add an event called {$_POST['name']} which takes place on:
"; 15 | 16 | // Print each weekday: 17 | if (isset($_POST['days']) AND is_array($_POST['days'])) { 18 | 19 | foreach ($_POST['days'] as $day) { 20 | print "$day
\n"; 21 | } 22 | 23 | } else { 24 | print 'Please select at least one weekday for this event!'; 25 | } 26 | 27 | // Complete the paragraph: 28 | print '

'; 29 | ?> 30 | 31 | -------------------------------------------------------------------------------- /07/list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | I Must Sort This Out! 6 | 7 | 8 | 9 |

Enter the words you want alphabetized with each individual word separated by a space:

10 | 11 |
12 | 13 | 14 | 15 | 16 |
17 |
18 | 19 | -------------------------------------------------------------------------------- /07/list.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | I Have This Sorted Out 6 | 7 | 8 | ', $words_array); 22 | 23 | // Print the results: 24 | print "

An alphabetized version of your list is:
$string_words

"; 25 | 26 | ?> 27 | 28 | -------------------------------------------------------------------------------- /07/sort.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | My Little Gradebook 6 | 7 | 8 | 95, 16 | 'Sherwood' => 82, 17 | 'Toni' => 98, 18 | 'Franz' => 87, 19 | 'Melissa' => 75, 20 | 'Roddy' => 85 21 | ]; 22 | 23 | // Print the original array: 24 | print '

Originally the array looks like this:
'; 25 | foreach ($grades as $student => $grade) { 26 | print "$student: $grade
\n"; 27 | } 28 | print '

'; 29 | 30 | // Sort by value in reverse order, then print again: 31 | arsort($grades); 32 | print '

After sorting the array by value using arsort(), the array looks like this:
'; 33 | foreach ($grades as $student => $grade) { 34 | print "$student: $grade
\n"; 35 | } 36 | print '

'; 37 | 38 | // Sort by key, then print again: 39 | ksort($grades); 40 | print '

After sorting the array by key using ksort(), the array looks like this:
'; 41 | foreach ($grades as $student => $grade) { 42 | print "$student: $grade
\n"; 43 | } 44 | print '

'; 45 | 46 | ?> 47 | 48 | -------------------------------------------------------------------------------- /07/soups1.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | No Soup for You! 6 | 7 | 8 |

Mmm...soups

9 | 'Clam Chowder', 16 | 'Tuesday' => 'White Chicken Chili', 17 | 'Wednesday' => 'Vegetarian' 18 | ]; 19 | 20 | // Try to print the array: 21 | print "

$soups

"; 22 | 23 | // Print the contents of the array: 24 | print_r($soups); 25 | 26 | ?> 27 | 28 | -------------------------------------------------------------------------------- /07/soups2.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | No Soup for You! 6 | 7 | 8 |

Mmm...soups

9 | 'Clam Chowder', 16 | 'Tuesday' => 'White Chicken Chili', 17 | 'Wednesday' => 'Vegetarian' 18 | ]; 19 | 20 | // Count and print the current number of elements: 21 | $count1 = count($soups); 22 | print "

The soups array originally had $count1 elements.

"; 23 | 24 | // Add three items to the array: 25 | $soups['Thursday'] = 'Chicken Noodle'; 26 | $soups['Friday'] = 'Tomato'; 27 | $soups['Saturday'] = 'Cream of Broccoli'; 28 | 29 | // Count and print the number of elements again: 30 | $count2 = count($soups); 31 | print "

After adding 3 more soups, the array now has $count2 elements.

"; 32 | 33 | // Print the contents of the array: 34 | print_r($soups); 35 | 36 | ?> 37 | 38 | -------------------------------------------------------------------------------- /07/soups3.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | No Soup for You! 6 | 7 | 8 |

Mmm...soups

9 | 'Clam Chowder', 17 | 'Tuesday' => 'White Chicken Chili', 18 | 'Wednesday' => 'Vegetarian', 19 | 'Thursday' => 'Chicken Noodle', 20 | 'Friday' => 'Tomato', 21 | 'Saturday' => 'Cream of Broccoli' 22 | ]; 23 | 24 | // Print each key and value: 25 | foreach ($soups as $day => $soup) { 26 | print "

$day: $soup

\n"; 27 | } 28 | 29 | ?> 30 | 31 | -------------------------------------------------------------------------------- /08/books.php: -------------------------------------------------------------------------------- 1 | 10 | 11 |

J.D. Salinger's Books

12 | 18 | 19 | -------------------------------------------------------------------------------- /08/css/concise.min.css: -------------------------------------------------------------------------------- 1 | :root{-ms-overflow-style:-ms-autohiding-scrollbar;overflow-y:scroll;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;text-size-adjust:100%}audio:not([controls]){display:none}details{display:block}input[type="number"]{width:auto}input[type="search"]{-webkit-appearance:textfield}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}main,summary{display:block}pre{overflow:auto}progress{display:inline-block}textarea{overflow:auto}template,[hidden]{display:none}[unselectable]{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}:root{box-sizing:border-box;color:#555;cursor:default;font-family:"Helvetica","Arial",sans-serif;font-size:14px;line-height:1.5;text-rendering:optimizeLegibility;vertical-align:top}@media(min-width:30em){:root{font-size:16px}}:root .nonresponsive{font-size:16px}*,::after,::before{box-sizing:inherit;color:inherit;font-family:inherit;font-size:inherit;line-height:inherit;text-decoration:inherit;vertical-align:inherit}*{cursor:inherit;margin:0;padding:0}body{background-color:white}a,button,input[type="submit"],input,select,textarea{cursor:initial}*[dir="rl;"]{direction:rtl;unicode-bidi:embed}bdo[dir="ltr"],bdo[dir="rtl"]{unicode-bidi:bidi-override}bdo[dir="ltr"]{direction:ltr}bdo[dir="rtl"]{direction:rtl}hr{border:0;border-top:1px solid #e0e0e0;display:block;height:1px;margin:20px 0}figure{margin:24px 1em}figcaption{color:#666;font-style:italic;text-align:center}::-moz-selection{background-color:#d6d6d6}::selection{background-color:#d6d6d6}::-moz-selection{background-color:#d6d6d6}blockquote{border-left:1px solid #e0e0e0;color:#666;margin-bottom:20px;padding:0 1em}blockquote cite,blockquote footer{display:block;font-size:80%;font-style:italic;margin-top:10px}blockquote cite:before,blockquote footer:before{content:"\2014 \00A0"}.blockquote--reverse{border-left:none;border-right:1px solid #e0e0e0;text-align:right}button,input[type="submit"],.button{background-color:#4591aa;border:0;color:white;cursor:pointer;display:inline-block;line-height:48px;overflow:visible;padding:0 2.5em;text-align:center;text-decoration:none;-webkit-transition:150ms;transition:150ms;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;vertical-align:middle;white-space:nowrap}button:hover,input[type="submit"]:hover,button:focus,input[type="submit"]:focus,.button:hover,.button:focus{background-color:#75b3c7;color:inherit;text-decoration:none}button:focus,input[type="submit"]:focus,button:active,input[type="submit"]:active,.button:focus,.button:active{outline:0}button:active,input[type="submit"]:active,.button:active{background-color:#63a8bf}button[disabled],input[disabled][type="submit"],.button[disabled]{background-color:gainsboro;color:white;cursor:not-allowed}.button--muted{background-color:#aaa}.button--muted:hover,.button--muted:focus{background-color:#d0d0d0}.button--muted:active{background-color:#c4c4c4}.button--primary{background-color:#4591aa}.button--primary:hover,.button--primary:focus{background-color:#75b3c7}.button--primary:active{background-color:#63a8bf}.button--success{background-color:#45ca69}.button--success:hover,.button--success:focus{background-color:#81db99}.button--success:active{background-color:#6dd589}.button--warning{background-color:#ffb800}.button--warning:hover,.button--warning:focus{background-color:#ffcd4d}.button--warning:active{background-color:#ffc633}.button--error{background-color:#ca4829}.button--error:hover,.button--error:focus{background-color:#df7961}.button--error:active{background-color:#db674b}.button--xsm{font-size:.75em;line-height:32px;padding:0 1.5em}.button--sm{font-size:.875em;line-height:40px;padding:0 2em}.button--lg{font-size:1.125em;line-height:56px;padding:0 3em}.button--xlg{font-size:1.125em;line-height:64px;padding:0 3.5em}.button--full{width:100%}.button--pill{border-radius:25px}.button--flat{background-color:transparent;color:#555}.button--flat:hover{background-color:rgba(0,0,0,0.1);color:#555}.button--flat[disabled]{background-color:transparent;color:#666}.button--collapse{width:100%}@media(min-width:30em){.button--collapse{width:auto}}@media(min-width:30em){form,form [row]{margin-bottom:24px}}.nonresponsive form,.nonresponsive form [row]{margin-bottom:24px}input:not([type="submit"]),select,textarea{border:1px solid #e0e0e0;border-radius:3px;font-size:.875em;height:32px;padding:0 .75em;-webkit-transition:150ms;transition:150ms;width:100%}input:not([type="submit"]):focus,select:focus,textarea:focus{border-color:#74cbe8;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px rgba(69,145,170,0.5);outline:0}input:not([type="submit"])[disabled],select[disabled],textarea[disabled]{background-color:#f5f5f5;cursor:not-allowed}input:not([type="submit"]){line-height:normal;min-height:24px}input:not([type="submit"])[type="checkbox"]:focus,input:not([type="submit"])[type="radio"]:focus,input:not([type="submit"])[type="range"]:focus,input:not([type="submit"])[type="file"]:focus,input:not([type="submit"])[type="color"]:focus,input:not([type="submit"])[type="submit"]:focus{border-color:transparent;box-shadow:none;outline:0}label{display:block;font-size:.875em}fieldset{border:1px solid #e0e0e0;border-radius:3px;padding:24px 1em;margin-bottom:24px}legend{font-size:.875em;font-weight:bold;padding:0 1em}input[type="checkbox"],input[type="file"],input[type="image"],input[type="radio"]{height:auto;width:auto}input[type="checkbox"],input[type="radio"]{line-height:normal;padding:0;vertical-align:middle}input[type="checkbox"]+label,input[type="radio"]+label{display:inline-block;margin:0 0 0 .5em;line-height:30px;vertical-align:middle}input[type="file"]{border:0;line-height:100%;padding:0}textarea{height:auto;padding:8px 1em;resize:vertical}select{background-color:transparent;border-radius:5px;padding:0}select[disabled]{color:#666}select[multiple]{height:auto}select::-ms-expand{display:none}select::-ms-value{color:currentColor}select option{padding:0 .75em}input[type="range"]{border:0;padding:0;width:100%;-webkit-appearance:none}input[type="range"]:focus{outline:0}input[type="range"]::-webkit-slider-runnable-track{background-color:gainsboro;border:0;border-radius:3px;height:5px}input[type="range"]::-webkit-slider-thumb{border:0;border-radius:50%;background-color:#4591aa;height:16px;margin-top:-5px;width:16px;-webkit-appearance:none}input[type="range"]::-moz-range-track{background-color:gainsboro;border:0;border-radius:3px;height:5px}input[type="range"]::-moz-range-thumb{border:0;border-radius:50%;background-color:#4591aa;height:16px;margin-top:-5px;width:16px}input[type="range"]::-ms-track{background-color:gainsboro;border:0;border-radius:3px;color:transparent;height:5px}input[type="range"]::-ms-thumb{border:0;border-radius:50%;background-color:#4591aa;height:16px;margin-top:-5px;width:16px}.input--help{color:#666;display:block;font-size:.75em;font-weight:bold;margin-top:8px}.form--inline input,.form--inline select,.form--inline textarea{margin-bottom:20px}@media(min-width:30em){.form--inline input,.form--inline select,.form--inline textarea{display:inline-block;margin-bottom:0;vertical-align:middle;width:auto}.form--inline label{display:inline;margin-right:.5em;vertical-align:middle}.form--inline input+label{margin-left:1em}}.nonresponsive .form--inline input,.nonresponsive .form--inline select,.nonresponsive .form--inline textarea{display:inline-block;margin-bottom:0;vertical-align:middle;width:auto}.nonresponsive .form--inline label{display:inline;margin-right:.5em;vertical-align:middle}.nonresponsive .form--inline input+label{margin-left:1em}.input--small{font-size:.75em;height:24px}.input--large{height:48px;font-size:1em}.input--flat{background-color:transparent;border-color:transparent;box-shadow:none}.input--flat:focus{border-color:#74cbe8}.input--success{background-color:rgba(69,202,105,0.15);border-color:#45ca69}.input--success:focus{border-color:#45ca69}.input--warning{background-color:rgba(255,184,0,0.15);border-color:#ffb800}.input--warning:focus{border-color:#ffb800}.input--error{background-color:rgba(202,72,41,0.15);border-color:#ca4829}.input--error:focus{border-color:#ca4829}h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6,.giga,.mega,.kilo{color:#222;font-family:"Helvetica","Arial",sans-serif;line-height:1.25em}h1 small,h1 .small,h2 small,h2 .small,h3 small,h3 .small,h4 small,h4 .small,h5 small,h5 .small,h6 small,h6 .small,.h1 small,.h1 .small,.h2 small,.h2 .small,.h3 small,.h3 .small,.h4 small,.h4 .small,.h5 small,.h5 .small,.h6 small,.h6 .small,.giga small,.giga .small,.mega small,.mega .small,.kilo small,.kilo .small{color:#666;font-weight:lighter;vertical-align:0}h1,h2,h3,.h1,.h2,.h3,.giga,.mega,.kilo{margin:20px 0 10px}h1 small,h1 .small,h2 small,h2 .small,h3 small,h3 .small,.h1 small,.h1 .small,.h2 small,.h2 .small,.h3 small,.h3 .small,.giga small,.giga .small,.mega small,.mega .small,.kilo small,.kilo .small{font-size:65%}h4,h5,h6,.h4,.h5,.h6{margin:10px 0}h4 small,h4 .small,h5 small,h5 .small,h6 small,h6 .small,.h4 small,.h4 .small,.h5 small,.h5 .small,.h6 small,.h6 .small{font-size:75%}h1,.h1{font-size:2.25em}@media(min-width:48em){h1,.h1{font-size:3em}}h2,.h2{font-size:1.6875em}@media(min-width:48em){h2,.h2{font-size:2.25em}}h3,.h3{font-size:1.3125em}@media(min-width:48em){h3,.h3{font-size:1.75em}}h4,.h4{font-size:1.125em}h5,.h5{font-size:1em}h6,.h6{font-size:.875em}.giga{font-size:3.75em}@media(min-width:48em){.giga{font-size:5em}}.mega{font-size:3em}@media(min-width:48em){.mega{font-size:4em}}.kilo{font-size:2.4375em}@media(min-width:48em){.kilo{font-size:3.25em}}.nonresponsive h1,.nonresponsive .h1{font-size:3em}.nonresponsive h2,.nonresponsive .h2{font-size:2.25em}.nonresponsive h3,.nonresponsive .h3{font-size:1.75em}.nonresponsive .giga{font-size:5em}.nonresponsive .mega{font-size:4em}.nonresponsive .kilo{font-size:3.25em}ul,ol{padding-left:1.5em;margin-bottom:10px}ul ul,ul ol,ol ul,ol ol{margin-bottom:0}ul ul{list-style-type:square}ul ol{list-style-type:lower-roman}ol ol{list-style-type:lower-roman}ol ul{list-style-type:square}.list--unstyled{list-style:none;padding-left:0}.list--unstyled li{padding-left:0}.list--inline{padding-left:0}.list--inline li{display:inline;list-style:none;padding-left:1.5em}.list--inline li:first-child{padding-left:0}dl{margin-bottom:24px}dt{font-weight:bold}dt,dd{margin-bottom:10px}@media(min-width:60em){.dl--horizontal dt{clear:left;float:left;overflow:hidden;text-align:right;text-overflow:ellipsis;white-space:nowrap;width:150px}.dl--horizontal dd{margin-left:165px}.dl--horizontal dd:before,.dl--horizontal dd:after{content:"";display:table}.dl--horizontal dd:after{clear:both}}.nonresponsive .dl--horizontal dt{clear:left;float:left;overflow:hidden;text-align:right;text-overflow:ellipsis;white-space:nowrap;width:150px}.nonresponsive .dl--horizontal dd{margin-left:165px}.nonresponsive .dl--horizontal dd:before,.nonresponsive .dl--horizontal dd:after{content:"";display:table}.nonresponsive .dl--horizontal dd:after{clear:both}@media print{@page{margin:.5cm}*,*:before,*:after{background:transparent!important;color:black!important;-webkit-filter:none!important;filter:none!important;text-shadow:none!important}:root{background-color:white;color:black;font:11pt/1.3 "Georgia","Times New Roman","Times",serif}img{max-width:100%!important;page-break-after:avoid;page-break-inside:avoid}.show--print{display:block;visibility:visible}.hide--print,video,audio,object,embed,nav,footer,a[href^="#"]:after{display:none;visibility:hidden}p,h2,h3,.h2,.h3{orphans:3;widows:3}h2,h3,.h2,.h3{page-break-after:avoid}a,a:visited{color:black;font-size:.57em;text-decoration:underline;word-wrap:break-word}a[href]:after,a:visited[href]:after{content:" (" attr(href) ")";font-size:smaller}q:after{content:" (Source: " attr(cite) ")"}abbr[title]:after{content:" (" attr(title) ")"}a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,code{background-color:none;border:1px solid #e0e0e0;page-break-inside:avoid}blockquote{border:0;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}ol{padding-left:1.25em}ul{padding-left:0;list-style:none}ul ul,ul ul ul{padding-left:1.5em}ul li,ol li{content:"» "}}@media print and (min-width:30em){table{page-break-inside:avoid;width:100%!important}table th,table td{line-height:40px!important}}@media print{.badge,.badge:before,.badge *:after,.label,.label:before,.label *:after,.spinner,.spinner:before,.spinner *:after,.tooltip,.tooltip:before,.tooltip *:after,[data-hint],[data-hint]:before,[data-hint] *:after,.progress,.progress:before,.progress *:after,.breadcrumbs,.breadcrumbs:before,.breadcrumbs *:after,.modal,.modal:before,.modal *:after,.alert,.alert:before,.alert *:after{display:none;visibility:hidden}}table{border:1px solid #e0e0e0;border-collapse:collapse;border-spacing:0;empty-cells:show;margin-bottom:24px;width:100%}table caption{color:#555;font-size:85%;font-style:italic;line-height:48px;text-align:center}table thead{background-color:#f5f5f5;text-align:left}table tfoot{background-color:#fbfbfb;border-top:1px solid #e0e0e0}table th,table td{border-right:1px solid #e0e0e0;line-height:24px;overflow:visible;padding:8px 1em}@media(min-width:30em){table th,table td{line-height:48px}}table th:last-child,table td:last-child{border-right:0}table tr,table td{-webkit-transition:background-color 150ms;transition:background-color 150ms}@media(min-width:30em){table{width:auto}table th,table td{padding:0 2.5em}}.nonresponsive{width:auto}.nonresponsive th,.nonresponsive td{padding:0 2.5em}.nonresponsive th,.nonresponsive td{line-height:48px}.table--responsive{overflow:auto;width:100%}.table--responsive::-webkit-scrollbar{height:14px;width:14px;-webkit-appearance:none}.table--responsive::-webkit-scrollbar-thumb{background-color:rgba(50,50,50,0.2);border:3px solid white;border-radius:8px}.table--responsive table{margin-bottom:0}.table--full{width:100%}.table--border{border:1px solid #e0e0e0}.table--border thead,.table--border td{border-bottom:1px solid #e0e0e0}.table--borderOuter{border:1px solid #e0e0e0}.table--borderOuter th,.table--borderOuter td{border-right:0}.table--borderHorizontal thead,.table--borderHorizontal td{border-bottom:1px solid #e0e0e0}.table--borderHorizontal th,.table--borderHorizontal td{border-right:0}.table--flat{border:0}.table--flat td{border-bottom:0}.table--flat th,.table--flat td{border-right:0}.table--fillEven tbody tr:nth-child(even){background-color:#f5f5f5}.table--fillOdd tbody tr:nth-child(odd){background-color:#f5f5f5}.table--hoverRow tbody tr:hover{background-color:#f5f5f5}.table--hoverCell tbody td:hover{background-color:#f5f5f5}i,em,.italic{font-style:italic}b,strong,.bold{font-weight:bold}small,.small{font-size:75%;vertical-align:text-bottom}sup,sub{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}s{text-decoration:line-through}p:not(:last-child){margin-bottom:20px}a{background-color:transparent;color:#4591aa;cursor:pointer;text-decoration:none;-webkit-transition:150ms;transition:150ms}a:hover,a:focus{color:#2f6374}h1 a,h2 a,h3 a,.h1 a,.h2 a,.h3 a{color:#555}h1 a:hover,h1 a:focus,h2 a:hover,h2 a:focus,h3 a:hover,h3 a:focus,.h1 a:hover,.h1 a:focus,.h2 a:hover,.h2 a:focus,.h3 a:hover,.h3 a:focus{color:#4591aa;text-decoration:none}abbr[title]{border-bottom:1px dotted #e0e0e0;cursor:help}code,pre,kbd,samp{font-family:"Consolas",monospace;font-size:.875em}pre{padding:16px 1.5em}code{vertical-align:middle;white-space:nowrap}code,pre{background-color:#f5f5f5;border:1px solid #e0e0e0;border-radius:3px;color:#484848;margin-bottom:24px}code{padding:2px 3px}pre code{background-color:transparent;border:0;padding:0;vertical-align:inherit;white-space:pre}.pre--flat{background-color:transparent;border:0;border-radius:none;padding:0}kbd{background-color:transparent;border:1px solid #e0e0e0;border-radius:3px;box-shadow:0 2px 0 -1px white,0 2px 0 gainsboro;display:inline-block;line-height:1.75;margin:-3px 2px 0;padding:2px 6px 0;white-space:nowrap}samp{vertical-align:bottom}address{font-style:normal}[container]{box-sizing:border-box;margin:0 auto;max-width:1200px;padding-left:15px;padding-right:15px;width:100%}[row]{margin-left:-15px;margin-right:-15px;margin-bottom:0}[row]:before,[row]:after{content:"";display:table}[row]:after{clear:both}[column]{box-sizing:border-box;float:left;margin-bottom:0;width:100%;padding-left:15px;padding-right:15px}@media(min-width:48em){[column~="1"]{width:8.33333%}[column~="2"]{width:16.66667%}[column~="3"]{width:25%}[column~="4"]{width:33.33333%}[column~="5"]{width:41.66667%}[column~="6"]{width:50%}[column~="7"]{width:58.33333%}[column~="8"]{width:66.66667%}[column~="9"]{width:75%}[column~="10"]{width:83.33333%}[column~="11"]{width:91.66667%}[column~="12"]{width:100%}[column~="+1"]{margin-left:8.33333%}[column~="+2"]{margin-left:16.66667%}[column~="+3"]{margin-left:25%}[column~="+4"]{margin-left:33.33333%}[column~="+5"]{margin-left:41.66667%}[column~="+6"]{margin-left:50%}[column~="+7"]{margin-left:58.33333%}[column~="+8"]{margin-left:66.66667%}[column~="+9"]{margin-left:75%}[column~="+10"]{margin-left:83.33333%}[column~="+11"]{margin-left:91.66667%}}.nonresponsive [column~="1"]{width:8.33333%}.nonresponsive [column~="2"]{width:16.66667%}.nonresponsive [column~="3"]{width:25%}.nonresponsive [column~="4"]{width:33.33333%}.nonresponsive [column~="5"]{width:41.66667%}.nonresponsive [column~="6"]{width:50%}.nonresponsive [column~="7"]{width:58.33333%}.nonresponsive [column~="8"]{width:66.66667%}.nonresponsive [column~="9"]{width:75%}.nonresponsive [column~="10"]{width:83.33333%}.nonresponsive [column~="11"]{width:91.66667%}.nonresponsive [column~="12"]{width:100%}.nonresponsive [column~="+1"]{margin-left:8.33333%}.nonresponsive [column~="+2"]{margin-left:16.66667%}.nonresponsive [column~="+3"]{margin-left:25%}.nonresponsive [column~="+4"]{margin-left:33.33333%}.nonresponsive [column~="+5"]{margin-left:41.66667%}.nonresponsive [column~="+6"]{margin-left:50%}.nonresponsive [column~="+7"]{margin-left:58.33333%}.nonresponsive [column~="+8"]{margin-left:66.66667%}.nonresponsive [column~="+9"]{margin-left:75%}.nonresponsive [column~="+10"]{margin-left:83.33333%}.nonresponsive [column~="+11"]{margin-left:91.66667%}.text--muted{color:#aaa!important}.bg--muted{background-color:#aaa!important}.text--primary{color:#4591aa!important}.bg--primary{background-color:#4591aa!important}.text--success{color:#45ca69!important}.bg--success{background-color:#45ca69!important}.text--warning{color:#ffb800!important}.bg--warning{background-color:#ffb800!important}.text--error{color:#ca4829!important}.bg--error{background-color:#ca4829!important}.show--xsm,.hide--sm,.hide--md,.hide--lg,.hide--xlg,.hide--print,.hide--hd{display:block;visibility:visible}.hide--xsm,.show--sm,.show--md,.show--lg,.show--xlg,.show--print,.show--hd{display:none;visibility:hidden}@media(min-width:48em){.show--sm,.hide--xsm,.hide--md,.hide--lg,.hide--xlg{display:block;visibility:visible}.hide--sm,.show--xsm,.show--md,.show--lg,.show--xlg{display:none;visibility:hidden}}@media(min-width:60em){.show--md,.hide--sm,.hide--xsm,.hide--lg,.hide--xlg{display:block;visibility:visible}.hide--md,.show--sm,.show--xsm,.show--lg,.show--xlg{display:none;visibility:hidden}}@media(min-width:70em){.show--lg,.hide--xsm,.hide--sm,.hide--md,.hide--xlg{display:block;visibility:visible}.hide--lg,.show--xsm,.show--sm,.show--md,.show--xlg{display:none;visibility:hidden}}@media(min-width:80em){.show--xlg,.hide--xsm,.hide--sm,.hide--md,.hide--lg{display:block;visibility:visible}.hide--xlg,.show--xsm,.show--sm,.show--md,.show--lg{display:none;visibility:hidden}}@media only screen and (-moz-min-device-pixel-ratio:1.5),only screen and (-o-min-device-pixel-ratio:3 / 2),only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (min-device-pixel-ratio:1.5){.show--hd{display:block;visibility:visible}.hide--hd{display:none;visibility:hidden}}.text--left{text-align:left}.text--center{text-align:center}.text--right{text-align:right}.text--justify{text-align:justify}.float--none{float:none}.float--right{float:right}.float--left{float:left}.clearfix:before,.clearfix:after{content:"";display:table}.clearfix:after{clear:both}.center--all{left:50%;position:absolute;text-align:center;top:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%)}.media--fluid{max-width:100%;height:auto}.screenreader{border:0 none;clip:rect(0,0,0,0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.screenreader:active,.screenreader:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}.alert{background-color:#f5f5f5;border:1px solid #e0e0e0;border-radius:3px;color:inherit;font-size:.875em;margin:20px 0;padding:8px 1em;position:relative}.alert a{color:#222}.alert a:hover{text-decoration:underline}.alert-close{color:inherit;float:right;opacity:.5;-webkit-transition:opacity 150ms;transition:opacity 150ms}.alert-close:hover{opacity:1}.alert-close:hover,.alert-close:focus{text-decoration:none}a.alert-close:hover{text-decoration:none}.alert--muted{background-color:rgba(170,170,170,0.15);border-color:rgba(170,170,170,0.2);color:#919191}.alert--muted a{color:#777}.alert--primary{background-color:rgba(69,145,170,0.15);border-color:rgba(69,145,170,0.2);color:#367286}.alert--primary a{color:#285361}.alert--success{background-color:rgba(69,202,105,0.15);border-color:rgba(69,202,105,0.2);color:#31ab52}.alert--success a{color:#25843f}.alert--warning{background-color:rgba(255,184,0,0.15);border-color:rgba(255,184,0,0.2);color:#cc9300}.alert--warning a{color:#996e00}.alert--error{background-color:rgba(202,72,41,0.15);border-color:rgba(202,72,41,0.2);color:#a03920}.alert--error a{color:#752a18}.badge{background-color:#4591aa;border-radius:25px;color:white;display:inline-block;font-size:.75em;line-height:24px;padding:0 .75em}.breadcrumbs{background-color:#f5f5f5;border:1px solid #e0e0e0;border-radius:3px;font-size:.75em;margin-bottom:24px;padding:8px .5em}.breadcrumbs li{display:inline;list-style:none;padding-left:.75em}.breadcrumbs li:after{color:#c7c7c7;content:"\002f";padding-left:.75em}.breadcrumbs li:last-child:after{content:"";padding-left:0}.breadcrumbs li.is-active,.breadcrumbs li.is-active a{color:#4d4d4d}.breadcrumbs--flat{background-color:transparent;border:0;border-radius:0;padding:0}.button--bordered{background-color:transparent;border:1px solid #4591aa;color:#4591aa}.button--bordered:hover,.button--bordered:focus{background-color:#4591aa;color:white}.border--muted{border-color:#aaa;color:#aaa}.border--muted:hover,.border--muted:focus{background-color:#aaa;color:white}.border--muted:active{background-color:#c4c4c4}.border--primary{border-color:#4591aa;color:#4591aa}.border--primary:hover,.border--primary:focus{background-color:#4591aa;color:white}.border--primary:active{background-color:#63a8bf}.border--success{border-color:#45ca69;color:#45ca69}.border--success:hover,.border--success:focus{background-color:#45ca69;color:white}.border--success:active{background-color:#6dd589}.border--warning{border-color:#ffb800;color:#ffb800}.border--warning:hover,.border--warning:focus{background-color:#ffb800;color:white}.border--warning:active{background-color:#ffc633}.border--error{border-color:#ca4829;color:#ca4829}.border--error:hover,.border--error:focus{background-color:#ca4829;color:white}.border--error:active{background-color:#db674b}.button--prefix{padding-left:0}.button--prefix .prefix{background-image:-webkit-linear-gradient(top,rgba(0,0,0,0.15),rgba(0,0,0,0.15));background-image:linear-gradient(to bottom,rgba(0,0,0,0.15),rgba(0,0,0,0.15));display:inline-block;margin-right:1.25em;padding:0 1em;vertical-align:0}.button--prefix.button--bordered .prefix{background-image:none;border-right:1px solid currentColor}.button--affix{padding-right:0}.button--affix .affix{background-image:-webkit-linear-gradient(top,rgba(0,0,0,0.15),rgba(0,0,0,0.15));background-image:linear-gradient(to bottom,rgba(0,0,0,0.15),rgba(0,0,0,0.15));display:inline-block;margin-left:1.25em;padding:0 1em;vertical-align:0}.button--affix.button--bordered .affix{background-image:none;border-left:1px solid currentColor}.card{background-color:white;border:1px solid #e0e0e0;margin-bottom:24px;overflow:hidden;position:relative}.card-content{padding:24px 1.5em}.card-title{display:block;margin-top:10px}.card-footer{border-top:1px solid #e0e0e0;font-size:.875em;padding:16px 1.5em}.card-image{position:relative}.card-image img{bottom:0;left:0;position:relative;right:0;top:0;width:100%}.card-image .card-title{bottom:0;color:white;left:0;padding:0 1em;position:absolute}.collection{border:1px solid #e0e0e0;border-radius:3px;list-style-type:none;margin:24px 0;padding:0}.collection-item,.collection-header{border-bottom:1px solid #e0e0e0;display:block;margin:0;padding:8px 1em}.collection-item:last-of-type,.collection-header:last-of-type{border-bottom:0}.collection-item.is-active,.collection-header.is-active{background-color:#f5f5f5}a.collection-item:hover{background-color:#f5f5f5}.collection-header{padding:0 1em}.dropdown{cursor:auto;display:inline-block;outline:0;position:relative}.dropdown:focus{pointer-events:none}.dropdown:focus .dropdown-content{opacity:1;visibility:visible}.dropdown.no-pointer-events{pointer-events:auto!important}.dropdown.no-visibility .dropdown-content{display:none;visibility:visible!important}.dropdown.no-visibility:focus .dropdown-content{display:block}.dropdown.no-opacity .dropdown-content{opacity:1!important}.dropdown-content{background-color:white;border:1px solid #e0e0e0;color:#555;left:0;margin-top:8px;opacity:0;padding:8px 1em;pointer-events:auto;position:absolute;text-align:left;-webkit-transition:all 150ms;transition:all 150ms;visibility:hidden;width:200px;z-index:1}.dropdown-content:before,.dropdown-content:after{border:solid transparent;bottom:100%;content:"";height:0;left:1.5em;pointer-events:none;position:absolute;width:0}.dropdown-content:before{border-color:rgba(255,255,255,0);border-bottom-color:#e0e0e0;border-width:7px;margin-left:-7px}.dropdown-content:after{border-color:rgba(255,255,255,0);border-bottom-color:white;border-width:6px;margin-left:-6px}.dropdown-content li{font-size:.875em;list-style-type:none;margin:0;padding:8px 1em;-webkit-transition:background-color 150ms;transition:background-color 150ms;white-space:nowrap}.dropdown-content li:hover{background-color:#f5f5f5}ul.dropdown-content,ol.dropdown-content{padding:0}.dropdown--hover:hover{pointer-events:none}.dropdown--hover:hover .dropdown-content{opacity:1;visibility:visible}.dropdown--small .dropdown-content{width:150px}.dropdown--large .dropdown-content{width:300px}.dropdown--top .dropdown-content{bottom:100%;margin-top:0;margin-bottom:8px}.dropdown--top .dropdown-content:before,.dropdown--top .dropdown-content:after{top:100%}.dropdown--top .dropdown-content:after{border-color:rgba(255,255,255,0);border-top-color:white}.dropdown--top .dropdown-content:before{border-color:rgba(255,255,255,0);border-top-color:#e0e0e0}.group{display:inline-block;margin-bottom:24px;padding:0}.group:before,.group:after{content:"";display:table}.group:after{clear:both}.group span{margin-top:0}.group-item{border:1px solid #e0e0e0;display:inline-block;float:left;font-size:.875em;line-height:32px;list-style:none;padding:0 1em;-webkit-transition:background-color 150ms;transition:background-color 150ms}.group-item:not(:first-child){margin:0 0 0 -1px}.group-item:hover{background-color:#f5f5f5}.group-item:first-child{border-radius:3px 0 0 3px}.group-item:last-child{border-radius:0 3px 3px 0}.group-item.is-active{background-color:#f5f5f5}.label{background-color:#4591aa;border-radius:3px;color:white;display:inline-block;font-size:.75em;line-height:24px;padding:0 1em}.modal{background-color:rgba(40,46,49,0.5);bottom:0;left:0;margin:0;opacity:0;overflow:scroll;pointer-events:none;position:fixed;right:0;top:0;-webkit-transition:opacity ease-in 150ms;transition:opacity ease-in 150ms;z-index:1000002}.modal:target{opacity:1;pointer-events:auto}.modal-container{box-shadow:0 1px 3px 0 rgba(0,0,0,0.1);margin:16px auto;position:relative;width:90%}@media(min-width:48em){.modal-container{width:526px}}@media(min-height:30em){.modal-container{margin:10% auto}}@media(min-height:48em){.modal-container{margin:15% auto}}.modal-header{background-color:#4591aa;color:white;padding:16px 1.5em}.modal-header h1,.modal-header h2,.modal-header h3,.modal-header h4,.modal-header h5,.modal-header h6,.modal-header .h1,.modal-header .h2,.modal-header .h3,.modal-header .h4,.modal-header .h5,.modal-header .h6,.modal-header .giga,.modal-header .mega,.modal-header .kilo{color:inherit;display:inline}.modal-body,.modal-footer{background-color:white;margin-top:0}.modal-body{padding:32px 2.5em}.modal-footer{border-top:1px solid #e0e0e0;font-size:.875em;margin:0;padding:24px 2.5em}.modal-close{color:white;float:right;margin:0;opacity:.5;-webkit-transition:opacity 150ms;transition:opacity 150ms}.modal-close:hover{opacity:1}.modal-close:hover,.modal-close:focus{text-decoration:none}.modal:target .modal-close--background{display:block;height:100%;pointer-events:all;position:absolute;width:100%}.modal:target .modal-close--background:hover{border-bottom:0;text-decoration:none}@media(min-width:48em){.modal--small .modal-container{width:360px}}@media(min-width:48em){.modal--large .modal-container{width:760px}}@media(min-width:48em){.modal--full .modal-container{width:90%}}.modal--flat .modal-header{background-color:white;color:#555;padding:1.5em 2.5em 0}.modal--flat .modal-header h1,.modal--flat .modal-header h2,.modal--flat .modal-header h3,.modal--flat .modal-header h4,.modal--flat .modal-header h5,.modal--flat .modal-header h6,.modal--flat .modal-header .h1,.modal--flat .modal-header .h2,.modal--flat .modal-header .h3,.modal--flat .modal-header .h4,.modal--flat .modal-header .h5,.modal--flat .modal-header .h6{color:inherit}.modal--flat .modal-close{color:#555;line-height:1;margin:0}.progress{background-color:#f5f5f5;border-radius:3px;box-shadow:inset 0 1px 1px rgba(224,224,224,0.25);box-sizing:initial;color:white;font-size:.6875em;height:14px;line-height:1.2;margin-bottom:24px;position:relative;text-align:center;width:100%}.progress>span{background-color:#4591aa;border-radius:3px;box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);display:block;height:100%;overflow:hidden;position:relative;width:auto}.progress--small{font-size:.5625em;height:10px;line-height:1.2}.progress--large{font-size:1em;height:25px;line-height:1.7}.progress--stacked>span{border-radius:0;display:inline-block;float:left;margin-top:0}.progress--stacked>span:first-of-type{border-radius:3px 0 0 3px}.progress--stacked>span:last-of-type{border-radius:0 3px 3px 0}.progress--striped>span:after,.progress--striped>span>span{background-image:-webkit-gradient(linear,0 0,100% 100%,color-stop(0.25,rgba(255,255,255,0.2)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.2)),color-stop(0.75,rgba(255,255,255,0.2)),color-stop(0.75,transparent),to(transparent));background-image:-moz-linear-gradient(-45deg,rgba(255,255,255,0.2) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.2) 50%,rgba(255,255,255,0.2) 75%,transparent 75%,transparent);background-size:50px 50px;bottom:0;content:"";left:0;overflow:hidden;position:absolute;right:0;top:0;z-index:1}.progress--striped.progress--animate>span:after,.progress--striped.progress--animate>span>span{-webkit-animation:move 2s linear infinite;animation:move 2s linear infinite}@keyframes move{0%{background-position:0 0}100%{background-position:50px 50px}}@-webkit-keyframes move{0%{background-position:0 0}100%{background-position:50px 50px}}.spinner{-webkit-animation:rotate .8s infinite linear;animation:rotate .8s infinite linear;border:3px solid #b5b5b5;border-radius:50%;border-right-color:transparent;height:30px;margin:24px auto;width:30px}@-webkit-keyframes rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes rotate{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.tooltip,[data-hint]{display:inline-block;position:relative}.tooltip:before,.tooltip:after,[data-hint]:before,[data-hint]:after{border-radius:2px;opacity:0;position:absolute;pointer-events:none;-webkit-transform:translate3d(0,0,0);transform:translate3d(0,0,0);-webkit-transition:100ms;transition:100ms;-webkit-transition-delay:0ms;transition-delay:0ms;visibility:hidden;z-index:1000000}.tooltip:before,[data-hint]:before{background-color:transparent;border:8px solid transparent;content:"";position:absolute;z-index:1000001}.tooltip:after,[data-hint]:after{background-color:#282e31;color:white;content:attr(data-hint);font-size:.75em;padding:.25em .5em;text-decoration:none;white-space:nowrap}.tooltip:hover:before,.tooltip:hover:after,.tooltip:focus:before,.tooltip:focus:after,[data-hint]:hover:before,[data-hint]:hover:after,[data-hint]:focus:before,[data-hint]:focus:after{opacity:1;visibility:visible}.tooltip:hover:before,.tooltip:hover:after,[data-hint]:hover:before,[data-hint]:hover:after{-webkit-transition-delay:100ms;transition-delay:100ms}.tooltip--top:before{border-top-color:#282e31;margin-bottom:-12px}.tooltip--top:after{margin-left:-18px}.tooltip--top:before,.tooltip--top:after{bottom:100%;left:50%}.tooltip--top:hover:after,.tooltip--top:hover:before{-webkit-transform:translateY(-8px);transform:translateY(-8px)}.tooltip--top:focus:after,.tooltip--top:focus:before{-webkit-transform:translateY(-8px);transform:translateY(-8px);-webkit-transition:150ms;transition:150ms}.tooltip--bottom:before{border-bottom-color:#282e31;margin-top:-12px}.tooltip--bottom:after{margin-left:-18px}.tooltip--bottom:before,.tooltip--bottom:after{left:50%;top:100%}.tooltip--bottom:hover:after,.tooltip--bottom:hover:before,.tooltip--bottom:focus:after,.tooltip--bottom:focus:before{-webkit-transform:translateY(8px);transform:translateY(8px)}.tooltip--right:before{border-right-color:#282e31;margin-bottom:-8px;margin-left:-12px}.tooltip--right:after{margin-bottom:-12px}.tooltip--right:before,.tooltip--right:after{bottom:50%;left:105%}.tooltip--right:hover:after,.tooltip--right:hover:before,.tooltip--right:focus:after,.tooltip--right:focus:before{-webkit-transform:translateX(8px);transform:translateX(8px)}.tooltip--left:before{border-left-color:#282e31;margin-bottom:-8px;margin-right:-12px}.tooltip--left:after{margin-bottom:-12px}.tooltip--left:before,.tooltip--left:after{bottom:50%;right:100%}.tooltip--left:hover:after,.tooltip--left:hover:before,.tooltip--left:focus:after,.tooltip--left:focus:before{-webkit-transform:translateX(-8px);transform:translateX(-8px)}.tooltip--always:before,.tooltip--always:after{opacity:1;visibility:visible}.tooltip--always .tooltip--top:before,.tooltip--always .tooltip--top:after{-webkit-transform:translateY(-8px);transform:translateY(-8px)}.tooltip--always .tooltip--right:before,.tooltip--always .tooltip--right:after{-webkit-transform:translateY(8px);transform:translateY(8px)}.tooltip--always .tooltip--bottom:before,.tooltip--always .tooltip--bottom:after{-webkit-transform:translateX(-8px);transform:translateX(-8px)}.tooltip--always .tooltip--left:before,.tooltip--always .tooltip--left:after{-webkit-transform:translateX(8px);transform:translateX(8px)} -------------------------------------------------------------------------------- /08/css/masthead.css: -------------------------------------------------------------------------------- 1 | .btn { 2 | /*border-radius: 4px;*/ 3 | /*transition: all .3s;*/ 4 | } 5 | 6 | .siteHeader { 7 | border-bottom: 1px solid #eee; 8 | } 9 | 10 | .logo { 11 | font-size: 22px; 12 | margin-bottom: 0; 13 | } 14 | 15 | .nav { text-align: right; } 16 | 17 | .nav li { 18 | display: inline; 19 | line-height: 4; 20 | margin-left: 25px; 21 | } 22 | .nav li:first-of-type { 23 | margin-left: 0; 24 | } 25 | 26 | .masthead { 27 | background-color: #eee; 28 | padding: 50px 0; 29 | } 30 | @media (min-width: 48em) { 31 | .masthead { 32 | padding: 100px 0; 33 | } 34 | } 35 | 36 | .masthead-title { 37 | margin-top: 0; 38 | } 39 | 40 | .siteContent { 41 | padding: 50px 0; 42 | } 43 | .siteFooter { 44 | border-top: 1px solid #eee; 45 | font-size: .875em; 46 | padding-top: 15px; 47 | } -------------------------------------------------------------------------------- /08/index.php: -------------------------------------------------------------------------------- 1 | 9 | 10 |

Welcome to a J.D. Salinger Fan Club!

11 |

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

12 | 13 | -------------------------------------------------------------------------------- /08/login.php: -------------------------------------------------------------------------------- 1 | Login Form 10 |

Users who are logged in can take advantage of certain features like this, that, and the other thing.

'; 11 | 12 | // Check if the form has been submitted: 13 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { 14 | 15 | // Handle the form: 16 | if ( (!empty($_POST['email'])) && (!empty($_POST['password'])) ) { 17 | 18 | if ( (strtolower($_POST['email']) == 'me@example.com') && ($_POST['password'] == 'testpass') ) { // Correct! 19 | 20 | print '

You are logged in!
Now you can blah, blah, blah...

'; 21 | 22 | } else { // Incorrect! 23 | 24 | print '

The submitted email address and password do not match those on file!
Go back and try again.

'; 25 | 26 | } 27 | 28 | } else { // Forgot a field. 29 | 30 | print '

Please make sure you enter both an email address and a password!
Go back and try again.

'; 31 | 32 | } 33 | 34 | } else { // Display the form. 35 | 36 | print '
37 |

38 |

39 |

40 |
'; 41 | 42 | } 43 | 44 | include('templates/footer.html'); // Need the footer. 45 | ?> -------------------------------------------------------------------------------- /08/register.php: -------------------------------------------------------------------------------- 1 | Registration Form 10 |

Register so that you can take advantage of certain features like this, that, and the other thing.

'; 11 | 12 | // Check if the form has been submitted: 13 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { 14 | 15 | $problem = false; // No problems so far. 16 | 17 | // Check for each value... 18 | if (empty($_POST['first_name'])) { 19 | $problem = true; 20 | print '

Please enter your first name!

'; 21 | } 22 | 23 | if (empty($_POST['last_name'])) { 24 | $problem = true; 25 | print '

Please enter your last name!

'; 26 | } 27 | 28 | if (empty($_POST['email'])) { 29 | $problem = true; 30 | print '

Please enter your email address!

'; 31 | } 32 | 33 | if (empty($_POST['password1'])) { 34 | $problem = true; 35 | print '

Please enter a password!

'; 36 | } 37 | 38 | if ($_POST['password1'] != $_POST['password2']) { 39 | $problem = true; 40 | print '

Your password did not match your confirmed password!

'; 41 | } 42 | 43 | if (!$problem) { // If there weren't any problems... 44 | 45 | // Print a message: 46 | print '

You are now registered!
Okay, you are not really registered but...

'; 47 | 48 | // Clear the posted values: 49 | $_POST = []; 50 | 51 | } else { // Forgot a field. 52 | 53 | print '

Please try again!

'; 54 | 55 | } 56 | 57 | } // End of handle form IF. 58 | 59 | // Create the form: 60 | ?> 61 |
62 | 63 |

64 | 65 |

66 | 67 |

68 | 69 |

70 |

71 | 72 |

73 | 74 |
75 | 76 | -------------------------------------------------------------------------------- /08/script_08_10/register.php: -------------------------------------------------------------------------------- 1 | Registration Form 10 |

Register so that you can take advantage of certain features like this, that, and the other thing.

'; 11 | 12 | // Check if the form has been submitted: 13 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { 14 | 15 | $problem = false; // No problems so far. 16 | 17 | // Check for each value... 18 | if (empty($_POST['first_name'])) { 19 | $problem = true; 20 | print '

Please enter your first name!

'; 21 | } 22 | 23 | if (empty($_POST['last_name'])) { 24 | $problem = true; 25 | print '

Please enter your last name!

'; 26 | } 27 | 28 | if (empty($_POST['email']) || (substr_count($_POST['email'], '@') != 1) ) { 29 | $problem = true; 30 | print '

Please enter your email address!

'; 31 | } 32 | 33 | if (empty($_POST['password1'])) { 34 | $problem = true; 35 | print '

Please enter a password!

'; 36 | } 37 | 38 | if ($_POST['password1'] != $_POST['password2']) { 39 | $problem = true; 40 | print '

Your password did not match your confirmed password!

'; 41 | } 42 | 43 | if (!$problem) { // If there weren't any problems... 44 | 45 | // Print a message: 46 | print '

You are now registered!
Okay, you are not really registered but...

'; 47 | 48 | // Send the email: 49 | $body = "Thank you, {$_POST['first_name']}, for registering with the J.D. Salinger fan club!'."; 50 | mail($_POST['email'], 'Registration Confirmation', $body, 'From: admin@example.com'); 51 | 52 | // Clear the posted values: 53 | $_POST = []; 54 | 55 | } else { // Forgot a field. 56 | 57 | print '

Please try again!

'; 58 | 59 | } 60 | 61 | } // End of handle form IF. 62 | 63 | // Create the form: 64 | ?> 65 |
66 | 67 |

68 | 69 |

70 | 71 |

72 | 73 |

74 |

75 | 76 |

77 | 78 |
79 | 80 | -------------------------------------------------------------------------------- /08/script_08_13/login.php: -------------------------------------------------------------------------------- 1 | Login Form 10 |

Users who are logged in can take advantage of certain features like this, that, and the other thing.

'; 11 | 12 | // Check if the form has been submitted: 13 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { 14 | 15 | // Handle the form: 16 | if ( (!empty($_POST['email'])) && (!empty($_POST['password'])) ) { 17 | 18 | if ( (strtolower($_POST['email']) == 'me@example.com') && ($_POST['password'] == 'testpass') ) { // Correct! 19 | 20 | // Redirect the user to the welcome page! 21 | ob_end_clean(); // Destroy the buffer! 22 | header('Location: welcome.php'); 23 | exit(); 24 | 25 | } else { // Incorrect! 26 | 27 | print '

The submitted email address and password do not match those on file!
Go back and try again.

'; 28 | 29 | } 30 | 31 | } else { // Forgot a field. 32 | 33 | print '

Please make sure you enter both an email address and a password!
Go back and try again.

'; 34 | 35 | } 36 | 37 | } else { // Display the form. 38 | 39 | print '
40 |

41 |

42 |

43 |
'; 44 | 45 | } 46 | 47 | include('templates/footer.html'); // Need the footer. 48 | ?> -------------------------------------------------------------------------------- /08/template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Raise High the Roof Beam! 9 | 10 | 11 | 12 | 13 | 14 | 28 | 29 |
30 | 31 |

Welcome to a J.D. Salinger Fan Club

32 |

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

33 | 34 |
35 | 36 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /08/templates/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /08/templates/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Raise High the Roof Beam! 9 | 10 | 11 | 12 | 13 | 14 | 28 | 29 |
30 | 31 | -------------------------------------------------------------------------------- /08/templates/script_08_06/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | <?php // Print the page title. 9 | if (defined('TITLE')) { // Is the title defined? 10 | print TITLE; 11 | } else { // The title is not defined. 12 | print 'Raise High the Roof Beam! A J.D. Salinger Fan Club'; 13 | } 14 | ?> 15 | 16 | 17 | 18 | 19 | 20 | 34 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /08/templates/script_08_07/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /08/templates/script_08_11/header.html: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | <?php // Print the page title. 14 | if (defined('TITLE')) { // Is the title defined? 15 | print TITLE; 16 | } else { // The title is not defined. 17 | print 'Raise High the Roof Beam! A J.D. Salinger Fan Club'; 18 | } 19 | ?> 20 | 21 | 22 | 23 | 24 | 25 | 39 | 40 |
41 | 42 | -------------------------------------------------------------------------------- /08/templates/script_08_12/footer.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /08/welcome.php: -------------------------------------------------------------------------------- 1 | 11 | 12 |

Welcome to the J.D. Salinger Fan Club!

13 |

You've successfully logged in and can now take advantage of everything the site has to offer.

14 |

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

15 | 16 | -------------------------------------------------------------------------------- /09/customize.php: -------------------------------------------------------------------------------- 1 | Your settings have been entered! Now see them in action.

'; 12 | 13 | } // End of submitted IF. 14 | ?> 15 | 16 | 17 | 18 | Customize Your Settings 19 | 20 | 21 | 26 | 27 |

Use this form to set your preferences:

28 | 29 |
30 | 40 | 48 | 49 |
50 | 51 | 52 | -------------------------------------------------------------------------------- /09/login.php: -------------------------------------------------------------------------------- 1 | Login Form 10 |

Users who are logged in can take advantage of certain features like this, that, and the other thing.

'; 11 | 12 | // Check if the form has been submitted: 13 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { 14 | 15 | // Handle the form: 16 | if ( (!empty($_POST['email'])) && (!empty($_POST['password'])) ) { 17 | 18 | if ( (strtolower($_POST['email']) == 'me@example.com') && ($_POST['password'] == 'testpass') ) { // Correct! 19 | 20 | // Do session stuff: 21 | session_start(); 22 | $_SESSION['email'] = $_POST['email']; 23 | $_SESSION['loggedin'] = time(); 24 | 25 | // Redirect the user to the welcome page! 26 | ob_end_clean(); // Destroy the buffer! 27 | header ('Location: welcome.php'); 28 | exit(); 29 | 30 | } else { // Incorrect! 31 | 32 | print '

The submitted email address and password do not match those on file!
Go back and try again.

'; 33 | 34 | } 35 | 36 | } else { // Forgot a field. 37 | 38 | print '

Please make sure you enter both an email address and a password!
Go back and try again.

'; 39 | 40 | } 41 | 42 | } else { // Display the form. 43 | 44 | print '
45 |

46 |

47 |

48 |
'; 49 | 50 | } 51 | 52 | include('templates/footer.html'); // Need the footer. 53 | ?> -------------------------------------------------------------------------------- /09/logout.php: -------------------------------------------------------------------------------- 1 | 18 | 19 |

Welcome to the J.D. Salinger Fan Club!

20 |

You are now logged out.

21 |

Thank you for using this site. We hope that you liked it.
22 | Blah, blah, blah... 23 | Blah, blah, blah...

24 | 25 | -------------------------------------------------------------------------------- /09/reset.php: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | Reset Your Settings 12 | 13 | 14 | 15 |

Your settings have been reset! Feel free to customize them again.

16 | 17 | 18 | -------------------------------------------------------------------------------- /09/script_09_03/customize.php: -------------------------------------------------------------------------------- 1 | Your settings have been entered! Now see them in action.

'; 12 | 13 | } // End of submitted IF. 14 | ?> 15 | 16 | 17 | 18 | Customize Your Settings 19 | 20 | 21 | 26 | 27 |

Use this form to set your preferences:

28 | 29 |
30 | 40 | 48 | 49 |
50 | 51 | 52 | -------------------------------------------------------------------------------- /09/script_09_05.txt: -------------------------------------------------------------------------------- 1 | email|s:14:"me@example.com";loggedin|i:1292883103; -------------------------------------------------------------------------------- /09/view_settings.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | View Your Settings 6 | 27 | 28 | 29 |

Customize Your Settings

30 |

Reset Your Settings

31 | 32 |

yadda yadda yadda yadda yadda 33 | yadda yadda yadda yadda yadda 34 | yadda yadda yadda yadda yadda 35 | yadda yadda yadda yadda yadda 36 | yadda yadda yadda yadda yadda

37 | 38 | 39 | -------------------------------------------------------------------------------- /09/welcome.php: -------------------------------------------------------------------------------- 1 | Welcome to the J.D. Salinger Fan Club!'; 14 | print '

Hello, ' . $_SESSION['email'] . '!

'; 15 | 16 | // Print how long they've been logged in: 17 | date_default_timezone_set('America/New_York'); 18 | print '

You have been logged in since: ' . date('g:i a', $_SESSION['loggedin']) . '.

'; 19 | 20 | // Make a logout link: 21 | print '

Logout

'; 22 | 23 | include('templates/footer.html'); // Need the footer. 24 | ?> -------------------------------------------------------------------------------- /10/calculator1.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Cost Calculator 6 | 7 | 8 | Your total comes to $$total.

"; 31 | 32 | } else { // Inappropriate values entered. 33 | print '

Please enter a valid quantity and price!

'; 34 | } 35 | 36 | } 37 | ?> 38 |
39 |

Quantity:

40 |

Price:

41 | 42 |
43 | 44 | 45 | -------------------------------------------------------------------------------- /10/calculator2.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Cost Calculator 6 | 7 | 8 | Your total comes to $$total, including the $tax percent tax rate.

"; 38 | 39 | } else { // Inappropriate values entered. 40 | print '

Please enter a valid quantity and price!

'; 41 | } 42 | 43 | } 44 | ?> 45 |
46 |

Quantity:

47 |

Price:

48 | 49 | 50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /10/menus.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Date Menus 6 | 7 | 8 | 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; 16 | 17 | // Make the month pull-down menu: 18 | print ''; 23 | 24 | // Make the day pull-down menu: 25 | print ''; 30 | 31 | // Make the year pull-down menu: 32 | print ''; 38 | 39 | } // End of make_date_menus() function. 40 | 41 | // Make the form: 42 | print '
'; 43 | make_date_menus(); 44 | print '
'; 45 | 46 | ?> 47 | 48 | -------------------------------------------------------------------------------- /10/sticky1.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Sticky Text Inputs 6 | 7 | 8 |

'; 28 | 29 | } // End of make_text_input() function. 30 | 31 | // Make the form: 32 | print '
'; 33 | 34 | // Create some text inputs: 35 | make_text_input('first_name', 'First Name'); 36 | make_text_input('last_name', 'Last Name'); 37 | make_text_input('email', 'Email Address'); 38 | 39 | print '
'; 40 | 41 | ?> 42 | 43 | -------------------------------------------------------------------------------- /10/sticky2.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Sticky Text Inputs 6 | 7 | 8 |

'; 29 | 30 | } // End of make_text_input() function. 31 | 32 | // Make the form: 33 | print '
'; 34 | 35 | // Create some text inputs: 36 | make_text_input('first_name', 'First Name'); 37 | make_text_input('last_name', 'Last Name', 30); 38 | make_text_input('email', 'Email Address', 50); 39 | 40 | print '
'; 41 | 42 | ?> 43 | 44 | -------------------------------------------------------------------------------- /11/add_quote.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Add A Quotation 6 | 7 | 8 | Your quotation has been stored.

'; 25 | 26 | } else { // Could not open the file. 27 | print '

Your quotation could not be stored due to a system error.

'; 28 | } 29 | 30 | } else { // Failed to enter a quotation. 31 | print '

Please enter a quotation!

'; 32 | } 33 | 34 | } // End of submitted IF. 35 | 36 | // Leave PHP and display the form: 37 | ?> 38 | 39 |
40 |
41 | 42 |
43 | 44 | 45 | -------------------------------------------------------------------------------- /11/list_dir.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Directory Contents 6 | 7 | 8 | Directories 21 | '; // Close the list. 29 | 30 | // Create a table header: 31 | print '

Files

32 | 33 | 34 | 35 | 36 | 37 | '; 38 | 39 | // List the files: 40 | foreach ($contents as $item) { 41 | if ( (is_file($search_dir . '/' . $item)) AND (substr($item, 0, 1) != '.') ) { 42 | 43 | // Get the file size: 44 | $fs = filesize($search_dir . '/' . $item); 45 | 46 | // Get the file's modification date: 47 | $lm = date('F j, Y', filemtime($search_dir . '/' . $item)); 48 | 49 | // Print the information: 50 | print " 51 | 52 | 53 | 54 | \n"; 55 | 56 | } // Close the IF. 57 | 58 | } // Close the FOREACH. 59 | 60 | print '
NameSizeLast Modified
$item$fs bytes$lm
'; // Close the HTML table. 61 | 62 | ?> 63 | 64 | -------------------------------------------------------------------------------- /11/login.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Login 6 | 7 | 8 |

Login

9 | You are now logged in.

'; 45 | } else { 46 | print '

The username and password you entered do not match those on file.

'; 47 | } 48 | 49 | } else { // Display the form. 50 | 51 | // Leave PHP and display the form: 52 | ?> 53 | 54 |
55 |

Username:

56 |

Password:

57 | 58 |
59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /11/register.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Register 6 | 9 | 10 | 11 |

Register

12 | Please enter a username!

'; 27 | } 28 | 29 | if (empty($_POST['password1'])) { 30 | $problem = TRUE; 31 | print '

Please enter a password!

'; 32 | } 33 | 34 | if ($_POST['password1'] != $_POST['password2']) { 35 | $problem = TRUE; 36 | print '

Your password did not match your confirmed password!

'; 37 | } 38 | 39 | if (!$problem) { // If there weren't any problems... 40 | 41 | if (is_writable($file)) { // Open the file. 42 | 43 | // Create the data to be written: 44 | $subdir = time() . rand(0, 4596); 45 | $data = $_POST['username'] . "\t" . sha1(trim($_POST['password1'])) . "\t" . $subdir . PHP_EOL; 46 | 47 | // Write the data: 48 | file_put_contents($file, $data, FILE_APPEND | LOCK_EX); 49 | 50 | // Create the directory: 51 | mkdir ($dir . $subdir); 52 | 53 | // Print a message: 54 | print '

You are now registered!

'; 55 | 56 | } else { // Couldn't write to the file. 57 | print '

You could not be registered due to a system error.

'; 58 | } 59 | 60 | } else { // Forgot a field. 61 | print '

Please go back and try again!

'; 62 | } 63 | 64 | } else { // Display the form. 65 | 66 | // Leave PHP and display the form: 67 | ?> 68 | 69 |
70 |

Username:

71 |

Password:

72 |

Confirm Password:

73 | 74 |
75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /11/script_11_02/add_quote.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Add A Quotation 6 | 7 | 8 | Your quotation has been stored.

'; 25 | 26 | } else { // Could not open the file. 27 | print '

Your quotation could not be stored due to a system error.

'; 28 | } 29 | 30 | } else { // Failed to enter a quotation. 31 | print '

Please enter a quotation!

'; 32 | } 33 | 34 | } // End of submitted IF. 35 | 36 | // Leave PHP and display the form: 37 | ?> 38 | 39 |
40 |
41 | 42 |
43 | 44 | 45 | -------------------------------------------------------------------------------- /11/upload_file.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Upload a File 6 | 7 | 8 | Your file has been uploaded.

'; 17 | 18 | } else { // Problem! 19 | 20 | print '

Your file could not be uploaded because: '; 21 | 22 | // Print a message based upon the error: 23 | switch ($_FILES['the_file']['error']) { 24 | case 1: 25 | print 'The file exceeds the upload_max_filesize setting in php.ini'; 26 | break; 27 | case 2: 28 | print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form'; 29 | break; 30 | case 3: 31 | print 'The file was only partially uploaded'; 32 | break; 33 | case 4: 34 | print 'No file was uploaded'; 35 | break; 36 | case 6: 37 | print 'The temporary folder does not exist.'; 38 | break; 39 | default: 40 | print 'Something unforeseen happened.'; 41 | break; 42 | } 43 | 44 | print '.

'; // Complete the paragraph. 45 | 46 | } // End of move_uploaded_file() IF. 47 | 48 | } // End of submission IF. 49 | 50 | // Leave PHP and display the form: 51 | ?> 52 | 53 |
54 |

Upload a file using this form:

55 | 56 |

57 |

58 |
59 | 60 | 61 | -------------------------------------------------------------------------------- /11/users.txt: -------------------------------------------------------------------------------- 1 | larry 9d4e1e23bd5b727046a9e3b4b7db57bd8d6ee684 14615086124319 2 | john 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8 14615086364092 3 | paul f0578f1e7174b1a41c4ea8c6e17f7a8a3b88c92a 14615086461481 4 | george 81fe8bfe87576c3ecb22426f8e57847382917acf 14615252264106 5 | ringo c2543fff3bfa6f144c2f06a7de6cd10c0b650cae 1461525233328 6 | -------------------------------------------------------------------------------- /11/view_quote.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | View A Quotation 6 | 7 | 8 |

Random Quotation

9 | ' . trim($data[$rand]) . '

'; 23 | 24 | ?> 25 | 26 | -------------------------------------------------------------------------------- /12/add_entry.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Add a Blog Entry 6 | 7 | 8 |

Add a Blog Entry

9 | Please submit both a title and an entry.

'; 21 | $problem = TRUE; 22 | } 23 | 24 | if (!$problem) { 25 | 26 | // Connect and select: 27 | $dbc = mysqli_connect('localhost', 'username', 'password', 'myblog'); 28 | 29 | // Define the query: 30 | $query = "INSERT INTO entries (id, title, entry, date_entered) VALUES (0, '$title', '$entry', NOW())"; 31 | 32 | // Execute the query: 33 | if (@mysqli_query($dbc, $query)) { 34 | print '

The blog entry has been added!

'; 35 | } else { 36 | print '

Could not add the entry because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 37 | } 38 | 39 | mysqli_close($dbc); // Close the connection. 40 | 41 | } // No problem! 42 | 43 | } // End of form submission IF. 44 | 45 | // Display the form: 46 | ?> 47 |
48 |

Entry Title:

49 |

Entry Text:

50 | 51 |
52 | 53 | -------------------------------------------------------------------------------- /12/create_table.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Create a Table 6 | 7 | 8 | The table has been created!

'; 25 | } else { 26 | print '

Could not create the table because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 27 | } 28 | 29 | mysqli_close($dbc); // Close the connection. 30 | 31 | } else { // Connection failure. 32 | print '

Could not connect to the database:
' . mysqli_connect_error() . '.

'; 33 | } 34 | ?> 35 | 36 | -------------------------------------------------------------------------------- /12/delete_entry.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Delete a Blog Entry 6 | 7 | 8 |

Delete an Entry

9 | 25 |

Are you sure you want to delete this entry?

26 |

' . $row['title'] . '

' . 27 | $row['entry'] . '
28 | 29 |

30 | '; 31 | 32 | } else { // Couldn't get the information. 33 | print '

Could not retrieve the blog entry because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 34 | } 35 | 36 | } elseif (isset($_POST['id']) && is_numeric($_POST['id'])) { // Handle the form. 37 | 38 | // Define the query: 39 | $query = "DELETE FROM entries WHERE id={$_POST['id']} LIMIT 1"; 40 | $r = mysqli_query($dbc, $query); // Execute the query. 41 | 42 | // Report on the result: 43 | if (mysqli_affected_rows($dbc) == 1) { 44 | print '

The blog entry has been deleted.

'; 45 | } else { 46 | print '

Could not delete the blog entry because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 47 | } 48 | 49 | } else { // No ID received. 50 | print '

This page has been accessed in error.

'; 51 | } // End of main IF. 52 | 53 | mysqli_close($dbc); // Close the connection. 54 | 55 | ?> 56 | 57 | -------------------------------------------------------------------------------- /12/edit_entry.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Edit a Blog Entry 6 | 7 | 8 |

Edit an Entry

9 | 28 |

Entry Title:

29 |

Entry Text:

30 | 31 | 32 | '; 33 | 34 | } else { // Couldn't get the information. 35 | print '

Could not retrieve the blog entry because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 36 | } 37 | 38 | } elseif (isset($_POST['id']) && is_numeric($_POST['id'])) { // Handle the form. 39 | 40 | // Validate and secure the form data: 41 | $problem = FALSE; 42 | if (!empty($_POST['title']) && !empty($_POST['entry'])) { 43 | $title = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['title']))); 44 | $entry = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['entry']))); 45 | } else { 46 | print '

Please submit both a title and an entry.

'; 47 | $problem = TRUE; 48 | } 49 | 50 | if (!$problem) { 51 | 52 | // Define the query. 53 | $query = "UPDATE entries SET title='$title', entry='$entry' WHERE id={$_POST['id']}"; 54 | $r = mysqli_query($dbc, $query); // Execute the query. 55 | 56 | // Report on the result: 57 | if (mysqli_affected_rows($dbc) == 1) { 58 | print '

The blog entry has been updated.

'; 59 | } else { 60 | print '

Could not update the entry because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 61 | } 62 | 63 | } // No problem! 64 | 65 | } else { // No ID set. 66 | print '

This page has been accessed in error.

'; 67 | } // End of main IF. 68 | 69 | mysqli_close($dbc); // Close the connection. 70 | 71 | ?> 72 | 73 | -------------------------------------------------------------------------------- /12/mysqli_connect.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Connect to MySQL 6 | 7 | 8 | Successfully connected to the database!

'; 15 | 16 | mysqli_close($dbc); // Close the connection. 17 | 18 | } else { 19 | 20 | print '

Could not connect to the database.

'; 21 | 22 | } 23 | 24 | ?> 25 | 26 | -------------------------------------------------------------------------------- /12/script_12_02/mysqli_connect.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Connect to MySQL 6 | 7 | 8 | Successfully connected to the database!

'; 15 | 16 | mysqli_close($dbc); // Close the connection. 17 | 18 | } else { 19 | 20 | print '

Could not connect to the database:
' . mysqli_connect_error() . '.

'; 21 | 22 | } 23 | 24 | ?> 25 | 26 | -------------------------------------------------------------------------------- /12/script_12_05/add_entry.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Add a Blog Entry 6 | 7 | 8 |

Add a Blog Entry

9 | Please submit both a title and an entry.

'; 27 | $problem = TRUE; 28 | } 29 | 30 | if (!$problem) { 31 | 32 | // Define the query: 33 | $query = "INSERT INTO entries (id, title, entry, date_entered) VALUES (0, '$title', '$entry', NOW())"; 34 | 35 | // Execute the query: 36 | if (@mysqli_query($dbc, $query)) { 37 | print '

The blog entry has been added!

'; 38 | } else { 39 | print '

Could not add the entry because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 40 | } 41 | 42 | } // No problem! 43 | 44 | mysqli_close($dbc); // Close the connection. 45 | 46 | } // End of form submission IF. 47 | 48 | // Display the form: 49 | ?> 50 |
51 |

Entry Title:

52 |

Entry Text:

53 | 54 |
55 | 56 | -------------------------------------------------------------------------------- /12/view_entries.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | View My Blog 6 | 7 | 8 |

My Blog

9 |

{$row['title']}

23 | {$row['entry']}
24 | Edit 25 | Delete 26 |


\n"; 27 | } 28 | 29 | } else { // Query didn't run. 30 | print '

Could not retrieve the data because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 31 | } // End of query IF. 32 | 33 | mysqli_close($dbc); // Close the connection. 34 | 35 | ?> 36 | 37 | -------------------------------------------------------------------------------- /13/htdocs/add_quote.php: -------------------------------------------------------------------------------- 1 | Add a Quotation'; 9 | 10 | // Restrict access to administrators only: 11 | if (!is_administrator()) { 12 | print '

Access Denied!

You do not have permission to access this page.

'; 13 | include('templates/footer.html'); 14 | exit(); 15 | } 16 | 17 | // Check for a form submission: 18 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { // Handle the form. 19 | 20 | if ( !empty($_POST['quote']) && !empty($_POST['source']) ) { 21 | 22 | // Need the database connection: 23 | include('../mysqli_connect.php'); 24 | 25 | // Prepare the values for storing: 26 | $quote = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['quote']))); 27 | $source = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['source']))); 28 | 29 | // Create the "favorite" value: 30 | if (isset($_POST['favorite'])) { 31 | $favorite = 1; 32 | } else { 33 | $favorite = 0; 34 | } 35 | 36 | $query = "INSERT INTO quotes (quote, source, favorite) VALUES ('$quote', '$source', $favorite)"; 37 | mysqli_query($dbc, $query); 38 | 39 | if (mysqli_affected_rows($dbc) == 1){ 40 | // Print a message: 41 | print '

Your quotation has been stored.

'; 42 | } else { 43 | print '

Could not store the quote because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 44 | } 45 | 46 | // Close the connection: 47 | mysqli_close($dbc); 48 | 49 | } else { // Failed to enter a quotation. 50 | print '

Please enter a quotation and a source!

'; 51 | } 52 | 53 | } // End of submitted IF. 54 | 55 | // Leave PHP and display the form: 56 | ?> 57 | 58 |
59 |

60 |

61 |

62 |

63 |
64 | 65 | -------------------------------------------------------------------------------- /13/htdocs/css/style.css: -------------------------------------------------------------------------------- 1 | @charset "utf-8"; 2 | /* CSS Coded and Designed by Nathan Chapman */ 3 | /* from Pixl Design - http://pixl.utopiaplanitia.org */ 4 | 5 | /* --------- RESET --------- */ 6 | /* Don't forget to set a foreground and background color 7 | on the 'html' or 'body' element! */ 8 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dd,dl,dt,li,ol,ul,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{ margin:0; padding:0; border:0; font-weight:inherit; font-style:inherit; font-size:100%; line-height:1.2; font-family:Geneva, Arial, Helvetica, sans-serif; text-align:left; vertical-align:baseline; } 9 | a img,:link img,:visited img{ border:0; } 10 | table{ border-collapse:collapse; border-spacing:0; } 11 | ol,ul{ list-style:none; } 12 | q:before,q:after,blockquote:before,blockquote:after{ content:""; } 13 | 14 | /* --------- Universal --------- */ 15 | body{ background:#fefefe; color:#AAA; } 16 | 17 | /* --------- Links --------- */ 18 | a:link,a:visited{ text-decoration:none; color:#666; border-bottom:1px #999 dashed; } 19 | a:hover,a:active{ color:#333; border-bottom:1px #333 solid; } 20 | 21 | /* --------- Layout --------- */ 22 | #container{ margin:20px auto 30px; width:65%; } 23 | #footer{ color:#999; font-size:75%; margin-bottom:50px; text-align:center; } 24 | 25 | /* --------- Header Tags --------- */ 26 | h1,h2,h3,h4,h5,h6{ color:#999; font-weight:bolder; padding:10px 15px 0px 15px; } 27 | h1{ font-size:36px; } 28 | h2{ font-size:24px; } 29 | h3{ font-size:18px; } 30 | h4{ font-size:16px; } 31 | h5{ font-size:14px; } 32 | h6{ font-size:12px; } 33 | 34 | /* --------- Typography --------- */ 35 | p{ font-size:medium; line-height:2; } 36 | ul,ol{ margin:25px; } 37 | ul li, ol li { padding-left:10px; } 38 | ul{ list-style:square inside; } 39 | ol{ list-style:decimal inside; } 40 | blockquote{ margin:15px; border-left:5px #FFDF00 solid; padding:7px; color:#999; font-style:italic; } 41 | pre { margin:10px; border-left:5px #FFDF00 double; padding:10px; font-family:"Courier New", Courier, monospace; } 42 | 43 | /* --------- Yellow Stops --------- */ 44 | h1:after,h2:after,h3:after,h4:after,h5:after,h6:after,li:after{ content:"."; color:#FFDF00; font-family:Helvatica, Arial, sans-serif; } 45 | li:after{ font-size:24px; } 46 | 47 | p { margin-top: 1em; } 48 | 49 | .error { 50 | color: red; 51 | } -------------------------------------------------------------------------------- /13/htdocs/delete_quote.php: -------------------------------------------------------------------------------- 1 | Delete a Quotation'; 9 | 10 | // Restrict access to administrators only: 11 | if (!is_administrator()) { 12 | print '

Access Denied!

You do not have permission to access this page.

'; 13 | include('templates/footer.html'); 14 | exit(); 15 | } 16 | 17 | // Need the database connection: 18 | include('../mysqli_connect.php'); 19 | 20 | if (isset($_GET['id']) && is_numeric($_GET['id']) && ($_GET['id'] > 0) ) { // Display the quote in a form: 21 | 22 | // Define the query: 23 | $query = "SELECT quote, source, favorite FROM quotes WHERE id={$_GET['id']}"; 24 | if ($result = mysqli_query($dbc, $query)) { // Run the query. 25 | 26 | $row = mysqli_fetch_array($result); // Retrieve the information. 27 | 28 | // Make the form: 29 | print '
30 |

Are you sure you want to delete this quote?

31 |
' . $row['quote'] . '
- ' . $row['source']; 32 | 33 | // Is this a favorite? 34 | if ($row['favorite'] == 1) { 35 | print ' Favorite!'; 36 | } 37 | 38 | print '

39 |

40 |
'; 41 | 42 | } else { // Couldn't get the information. 43 | print '

Could not retrieve the quote because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 44 | } 45 | 46 | } elseif (isset($_POST['id']) && is_numeric($_POST['id']) && ($_POST['id'] > 0) ) { // Handle the form. 47 | 48 | // Define the query: 49 | $query = "DELETE FROM quotes WHERE id={$_POST['id']} LIMIT 1"; 50 | $result = mysqli_query($dbc, $query); // Execute the query. 51 | 52 | // Report on the result: 53 | if (mysqli_affected_rows($dbc) == 1) { 54 | print '

The quote entry has been deleted.

'; 55 | } else { 56 | print '

Could not delete the blog entry because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 57 | } 58 | 59 | } else { // No ID received. 60 | print '

This page has been accessed in error.

'; 61 | } // End of main IF. 62 | 63 | mysqli_close($dbc); // Close the connection. 64 | 65 | include('templates/footer.html'); 66 | ?> -------------------------------------------------------------------------------- /13/htdocs/edit_quote.php: -------------------------------------------------------------------------------- 1 | Edit a Quotation'; 9 | 10 | // Restrict access to administrators only: 11 | if (!is_administrator()) { 12 | print '

Access Denied!

You do not have permission to access this page.

'; 13 | include('templates/footer.html'); 14 | exit(); 15 | } 16 | 17 | // Need the database connection: 18 | include('../mysqli_connect.php'); 19 | 20 | if (isset($_GET['id']) && is_numeric($_GET['id']) && ($_GET['id'] > 0) ) { // Display the entry in a form: 21 | 22 | // Define the query. 23 | $query = "SELECT quote, source, favorite FROM quotes WHERE id={$_GET['id']}"; 24 | if ($result = mysqli_query($dbc, $query)) { // Run the query. 25 | 26 | $row = mysqli_fetch_array($result); // Retrieve the information. 27 | 28 | // Make the form: 29 | print '
30 |

31 |

32 |

41 | 42 |

43 |
'; 44 | 45 | } else { // Couldn't get the information. 46 | print '

Could not retrieve the quotation because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 47 | } 48 | 49 | } elseif (isset($_POST['id']) && is_numeric($_POST['id']) && ($_POST['id'] > 0)) { // Handle the form. 50 | 51 | // Validate and secure the form data: 52 | $problem = FALSE; 53 | if ( !empty($_POST['quote']) && !empty($_POST['source']) ) { 54 | 55 | // Prepare the values for storing: 56 | $quote = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['quote']))); 57 | $source = mysqli_real_escape_string($dbc, trim(strip_tags($_POST['source']))); 58 | 59 | // Create the "favorite" value: 60 | if (isset($_POST['favorite'])) { 61 | $favorite = 1; 62 | } else { 63 | $favorite = 0; 64 | } 65 | 66 | } else { 67 | print '

Please submit both a quotation and a source.

'; 68 | $problem = TRUE; 69 | } 70 | 71 | if (!$problem) { 72 | 73 | // Define the query. 74 | $query = "UPDATE quotes SET quote='$quote', source='$source', favorite=$favorite WHERE id={$_POST['id']}"; 75 | if ($result = mysqli_query($dbc, $query)) { 76 | print '

The quotation has been updated.

'; 77 | } else { 78 | print '

Could not update the quotation because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 79 | } 80 | 81 | } // No problem! 82 | 83 | } else { // No ID set. 84 | print '

This page has been accessed in error.

'; 85 | } // End of main IF. 86 | 87 | mysqli_close($dbc); // Close the connection. 88 | 89 | include('templates/footer.html'); // Include the footer. 90 | ?> -------------------------------------------------------------------------------- /13/htdocs/includes/functions.php: -------------------------------------------------------------------------------- 1 |
{$row['quote']}
- {$row['source']}"; 31 | 32 | // Is this a favorite? 33 | if ($row['favorite'] == 1) { 34 | print ' Favorite!'; 35 | } 36 | 37 | // Complete the DIV: 38 | print ''; 39 | 40 | // If the admin is logged in, display admin links for this record: 41 | if (is_administrator()) { 42 | print "

Quote Admin: Edit <-> 43 | Delete 44 |

\n"; 45 | } 46 | 47 | } else { // Query didn't run. 48 | print '

Could not retrieve the data because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 49 | } // End of query IF. 50 | 51 | mysqli_close($dbc); // Close the connection. 52 | 53 | print '

Latest <-> Random <-> Favorite

'; 54 | 55 | include('templates/footer.html'); // Include the footer. 56 | ?> -------------------------------------------------------------------------------- /13/htdocs/login.php: -------------------------------------------------------------------------------- 1 | ' . $error . '

'; 43 | } 44 | 45 | // Indicate the user is logged in, or show the form: 46 | if ($loggedin) { 47 | 48 | print '

You are now logged in!

'; 49 | 50 | } else { 51 | 52 | print '

Login Form

53 |
54 |

55 |

56 |

57 |
'; 58 | 59 | } 60 | 61 | include('templates/footer.html'); // Need the footer. 62 | ?> -------------------------------------------------------------------------------- /13/htdocs/logout.php: -------------------------------------------------------------------------------- 1 | You are now logged out.

'; 15 | 16 | // Include the footer: 17 | include('templates/footer.html'); 18 | ?> -------------------------------------------------------------------------------- /13/htdocs/templates/footer.html: -------------------------------------------------------------------------------- 1 | 2 |

Site Admin

Add Quote <-> 12 | View All Quotes <-> 13 | Logout

'; 14 | 15 | } 16 | 17 | ?> 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /13/htdocs/templates/header.html: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | <?php // Print the page title. 11 | if (defined('TITLE')) { // Is the title defined? 12 | print TITLE; 13 | } else { // The title is not defined. 14 | print 'My Site of Quotes'; 15 | } 16 | ?> 17 | 18 | 19 |
20 |

My Site of Quotes

21 |
22 | -------------------------------------------------------------------------------- /13/htdocs/view_quotes.php: -------------------------------------------------------------------------------- 1 | All Quotes'; 9 | 10 | // Restrict access to administrators only: 11 | if (!is_administrator()) { 12 | print '

Access Denied!

You do not have permission to access this page.

'; 13 | include('templates/footer.html'); 14 | exit(); 15 | } 16 | 17 | // Need the database connection: 18 | include('../mysqli_connect.php'); 19 | 20 | // Define the query: 21 | $query = 'SELECT id, quote, source, favorite FROM quotes ORDER BY date_entered DESC'; 22 | 23 | // Run the query: 24 | if ($result = mysqli_query($dbc, $query)) { 25 | 26 | // Retrieve the returned records: 27 | while ($row = mysqli_fetch_array($result)) { 28 | 29 | // Print the record: 30 | print "
{$row['quote']}
- {$row['source']}\n"; 31 | 32 | // Is this a favorite? 33 | if ($row['favorite'] == 1) { 34 | print ' Favorite!'; 35 | } 36 | 37 | // Add administrative links: 38 | print "

Quote Admin: Edit <-> 39 | Delete

\n"; 40 | 41 | } // End of while loop. 42 | 43 | } else { // Query didn't run. 44 | print '

Could not retrieve the data because:
' . mysqli_error($dbc) . '.

The query being run was: ' . $query . '

'; 45 | } // End of query IF. 46 | 47 | mysqli_close($dbc); // Close the connection. 48 | 49 | include('templates/footer.html'); // Include the footer. 50 | ?> -------------------------------------------------------------------------------- /13/mysqli_connect.php: -------------------------------------------------------------------------------- 1 |