Before coming to Class 1, please complete the following tasks:
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Watch | Lecture | Week 7, continued | This lecture will be a crash course introduction to a programming language called PHP, which is often used for web programming. |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Watch | Doug's Playlist | PHP Syntax | Doug guides you through the basics of PHP syntax. He also introduces some new tools that PHP allows, such as: associative arrays, foreach loops, and default values for function arguments. Finally, he walks through some small example PHP programs in the IDE-- you might find it useful to treat this section as a Follow-Along exercise, copying and tinkering with the programs in your own workspace. |
| Read | Lecture Notes | Week 7, continued / PHP, Syntax | Read the "PHP" and "Syntax" section of the notes. This will give a quick overview of the PHP language, and also show some translations of code we're familiar with in C into code in PHP. Stop when you get to the Using PHP to Send Texts header. NOTE references to pset5 |
| Read | Resource | Helpful Resources / PHP Syntax Cheatsheet | Check out this cheatsheet on PHP syntax which includes helpful examples. |
| Do | Exercise | Lotto numbers | Learn about PHP foreach loops by finishing this program for reading lottery numbers |
| Do | Exercise | Getting Takeout | Learn about PHP associative arrays by writing a program to get takeout orders |
| Do | Exercise | Annoying Kid Brother | Learn about the PHP function array_push by completing a program that pesters you for a list, then repeats it to you in reverse. |
| Read | Lecture Notes | Week 7, continued / Using PHP to Send Texts | Review this section of the lecture where, using PHP, David (tries) to send a text message to everyone in class. Stop when you get to the Using PHP for Web Programming header. |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Read | Lecture Notes | Week 7, continued / Using PHP for Web Programming | Read these notes, which review how we can use PHP to write code that generates web pages. |
| Watch | Doug's Playlist | PHP for Web Development | Doug talks about the limitations of static HTML and why, in web development, we need a language like PHP on the backend to dynamically produce HTML content. He then shows us some examples of using PHP in this web context. |
| Follow-Along | Resource | Hello Server | Follow along with our tutorial as we serve up a Hello World program on the web. |
| Follow-Along | Walkthrough | froshims-0 | Here we create an HTML form which submits to a backend PHP script. In the PHP script, we are able to access all the data that came from the form via a special global variable, an associative-array called $_POST.You can find pseudocode to start this program here. |
| Read | Resource | Sending and Retreiving Form Data | This article from Mozilla explains what happens on the back end when we receive some data from a form. (It also begins with a good review of how data is sent from a form, which we learned in Module 6.) |
| Do | Exercise | Hello 0 | Practice working with data on the back end by enchancing our starter code. |
| Watch | Short | PHP Web Development | Tommy Macwilliam breaks down how we can mix HTML into our PHP code. |
| Follow-Along | Walkthrough | froshims-1 | Here we return to David's IM sports registration page, adding some logic on the back end which redirects users back to the form if they failed to fill out some of the fields. We also add some CSS styling to the form. You can find pseudocode to start this program here. |
| Do | Exercise | Hello 1 | In this exercise, we build on our program from Hello 0 by doing some validation. |
| Follow-Along | Walkthrough | froshims-2 | Here, instead of automatically redirecting the user, our backend script returns some HTML with a helpful error message and a clickable link to take them back to the form. You can find pseudocode to start this program here. |
| Do | Exercise | Hello 2 | Once again, we mirror the froshims walkthroughs in our own Hello site. This time you will provide a helpful message if the user filled out the form incorrectly. |
| Read | Resource | htmlspecialchars | Read about this very special function for those very special chars in your life. |
| Follow-Along | Walkthrough | froshims-3 | Finally, David shows how we can take some action with the successfully registered students: if they filled out the entire form, our backend script sends them a confirmation email. You can find pseudocode to start this program here. |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Watch | Short | PHP Sessions | Tommy talks about PHP Sessions, a built-in technology that uses cookies to allow you to remember data about your user for a longer period of time than just the current page they are one. |
| Follow-Along | Walkthrough | counter | An example site that makes use of PHP sessions. You can find pseudocode to start this program here. |
| Do | Exercise | Hello Sessions | Practice working with PHP sessions by doing another variation on the Hello! theme. |