Today is: 2024-11-20 | Current Unit: 02
A newsletter published by http://php.skillbuilderblocks.com/ to help students succeed! | |||||||||
Course: IT250 Enhancing Websites with PHP | Vol: 1301C | Issue: 1 | Date: 2013-02-28 | |||||||||
|
A newsletter published by http://php.skillbuilderblocks.com/ to help students succeed! | |||||||||
Course: IT250 Enhancing Websites with PHP | Vol: 1301C | Issue: 2 | Date: 2013-03-07 | |||||||||
|
A newsletter published by http://php.skillbuilderblocks.com/ to help students succeed! | |||||||||
Course: IT250 Enhancing Websites with PHP | Vol: 1301C | Issue: 3 | Date: 2013-03-14 | |||||||||
|
A newsletter published by http://php.skillbuilderblocks.com/ to help students succeed! | |||||||||
Course: IT250 Enhancing Websites with PHP | Vol: 1301C | Issue: 4 | Date: 2013-03-28 | |||||||||
|
A newsletter published by http://php.skillbuilderblocks.com/ to help students succeed! | |||||||||
Course: IT250 Enhancing Websites with PHP | Vol: 1301C | Issue: 5 | Date: 2013-04-04 | |||||||||
|
A newsletter published by http://php.skillbuilderblocks.com/ to help students succeed! | |||||||||
Course: IT250 Enhancing Websites with PHP | Vol: 1301C | Issue: 6 | Date: 2013-04-11 | |||||||||
|
A newsletter published by http://php.skillbuilderblocks.com/ to help students succeed! | |||||||||
Course: IT250 Enhancing Websites with PHP | Vol: 1301C | Issue: 7 | Date: 2013-04-18 | |||||||||
|
A newsletter published by http://php.skillbuilderblocks.com/ to help students succeed! | |||||||||
Course: IT250 Enhancing Websites with PHP | Vol: 1301C | Issue: 8 | Date: 2013-04-25 | |||||||||
|
A newsletter published by http://php.skillbuilderblocks.com/ to help students succeed! | |||||||||
Course: IT250 Enhancing Websites with PHP | Vol: 1301C | Issue: 9 | Date: 2013-05-02 | |||||||||
|
A newsletter published by http://php.skillbuilderblocks.com/ to help students succeed! | |||||||||
Course: IT250 Enhancing Websites with PHP | Vol: 1301C | Issue: 10 | Date: | |||||||||
|
The seminar recording covering the following topics is here http://khe2.adobeconnect.com/p4tqjg4fbqj/
The seminar recording covering the following topics is here http://khe2.adobeconnect.com/p1tz7v47xh4/
The seminar recording covering the following topics is here http://khe2.adobeconnect.com/p3iy3mo7xq3/
The seminar recording covering the following topics is here http://khe2.adobeconnect.com/p73z2zhr3os/
HINT: Think functions and their arguments, control structures, and array indexes
The seminar recording covering the following topics is here http://khe2.adobeconnect.com/p9p77kn6hlc/
The seminar recording covering the following topics is here http://khe2.adobeconnect.com/p8vs1zln246/
The seminar recording covering the following topics is here http://khe2.adobeconnect.com/p7lp4v9x2ru/
The seminar recording covering the following topics is here http://khe2.adobeconnect.com/p4cq10tvndf/
From the website http://www.wampserver.com/en/download.php you will download the latest copy of the WAMP software. The download location should be noted. When the download is complete you will double click on the file (or choose Run from the dialog box). The installer will prompt you to accept the license (click ok). It will then choose the location for the software to the default location of c:\wamp (click ok). It will create a shortcut folder in your start menu (click ok). The Auto Start option will load WAMP each time you boot your machine it should probably be unchecked. The install will now proceed.
Upon completion of the install, you will find a new folder in your C drive, named wamp. Upon opening that folder you will find a folder named 'www'. This is the root folder of your web server. To start the Server, click on Start>Programs>WAMP Server>Start WAMP Server. This begins a process that will show in the system tray (lower right of taskbar) as a 'dial'. You may click on the dial and select 'localhost' and you will see the default 'index' page for your server.
A video tutorial is available in the Reading section of this unit, named SavingFilesinWAMP.
Note: http://localhost/ is equivalent to http://127.0.0.1 used in your book.
Using a text editor (I recommend using Dreamweaver), create a simple PHP program, named myLastName.php mylastname.php (use your actual lastname: e.g. marrs.php, use all lower case and do not use spaces or any non-alphanumeric characters in file and folder names). The PHP program should echo your full name in H1 tags. See the examples for Unit 1 on the PHP support site here http://php.skillbuilderblocks.com/. Create a subfolder named unit01 in the www folder in the WAMP area. Save the file in that subfolder. Make sure WAMP is running and all services are turned on. Click the WAMP icon in the system tray and click Localhost to test the script (Localhost opens your default browser at this address: http://localhost/). Scroll down the page and under Your Projects, click the unit01 folder to open it and click the file that is listed there.
Be sure to refer to the rubrics for details on what's expected to earn full points!
Note that comments will not appear in the outputted results
The following examples both display the text string in the echo statement in the HTML <h4> format.
Be sure to refer to the rubrics for details on what's expected to earn full points!
Be sure to refer to the rubrics for details on what's expected to earn full points!
Be sure to refer to the rubrics for details on what's expected to earn full points!
This week you'll build on what you did in unit 4. The objective is to work on consistent layout and learn how to sort the data read from the text file alphabetically by last name.
NOTE: This week's project is worth 100 points, so give it your all!!
Be sure to refer to the rubrics for details on what's expected to earn full points!
This is the database you'll use for the remainder of the term through the final project. Use phpMyAdmin in your wamp services to create your database and tables. Please DO NOT make any changes to the root password or the privileges table as described in your book.
Be sure to refer to the rubrics for details on what's expected to earn full points!
Be sure to refer to the rubrics for details on what's expected to earn full points!
This project builds on Unit 7 and creates the foundation for Unit 9 and 10. (TIP: if your Unit 8 is fully built, you'll only have to modify your files for the remaining units.)
This project builds on Unit 8 and creates the foundation for Unit 10. (TIP: if your Unit 8 is fully built, you'll only have to modify your files for the remaining units.)
This project builds on Unit 9. (TIP: if your Unit 9 is fully built, you'll only have to modify your files for this unit.)
PHP is a server side language, meaning whenever the browser encounters <?php, called the php delimiter, the browser passes control to the server which then processes all code up until the server encounters the ?>, at which point the server passes control back to the browser. There are a few key things you need to know about server side code
Study the unit 1 demo screenshot and see if you can identify the points at which the browser or the server controls the flow.
HTTP allows you to send almost any type of data across the Internet to a Web server. Web sites use forms to obtain input from users. You can place many different fields into one form for user input. Such input can include user name, address, credit card number, email address, etc. The information entered by the user is then submitted to a server where it is stored and/or processed. To be truly functional, a form requires a Common Gateway Interface (CGI), which is created either server-side or client-side and written in a programming language (i.e. C, Perl, PHP). The script runs on the server. The script performs two important functions: It receives data from the browser, then it processes and formats the data.
The basic form elements include the <form> tag, which is a container tag requiring a closing tag and specifies the location of the script and the method used by the script.
Within the form tag, you can use a number of elements for capturing user input including the <input>, <select> and <textarea> tags. The <input> and <select> tags allow you to specify the type attribute such as whether it is a text box, radio button or select list. These tags and their attributes are discussed in greater detail in the next section.
All form field elements share the name attribute. The name attribute identifies the information you receive from a user and associates it with a value you specify and corresponds with the defined variables in the script. When the user submits the information, the server receives it a sraw data that is delimited a special way. The script can then parse and format the raw data into a human readable format. Notice in this example, the recipient field is hidden to the user and used only by the script, which uses the value (email address) to parse the data and send it to the recipient. Also note the two input types "submit" and "reset." These are built-in buttons that allow the user to submit the data or reset the form (NOTE: Form is just an image of what the code would look like in the browser and isn't actually functional. This is intentional for security reasons).
<form name="form" action="filename.php" method="post"></select>
Name: <input type="text" name="realname" size="25">
<input type="submit"><input type="reset">
The <input> tag is used to create a text box on the page, with the type attribute set to "text". The code for this would be: <input type="text">. Note that the <input> tag is not closed.
When dealing with text fields, be aware of cross-browser differences in their size. Netscape can make these fields very wide, so test in that browser to make sure that their size is acceptable and does not break your page layout. If the value for the type attribute is set to "password", when the user fills in the box the data is hidden by bullets or asterisks. However, no additional protection is provided. When the data is sent to the server, it is not encrypted or otherwise protected. This will only protect your data from someone looking over your shoulder! When to use text input fields: For short, discrete units of data, such as First Name, Last Name, Email Address, etc.
The <textarea> tag is used to create a textarea box on the page. Unlike the <input> tag, this tag needs to be closed.
Cross-browser size issues arise again. Be sure to check how the page looks in any browsers you expect your viewers to use! If the user enters enough data to fill the available rows, a vertical scrollbar will appear and the user can keep typing. When to use textarea boxes: These boxes are best for freeform, unstructured feedback. They are often used for submitting comments and questions.
The <input> tag is also used for radio buttons and check boxes. For radio bbuttons, the type attribute is set to "radio". Since you use the <input> tag, it does not need to be closed.
When to use radio buttons: Radio buttons should only be used for data in which one item is selected. To create check boxes, the type attribute is set to "checkbox".
Password boxes are simply text boxes that displays **** when the user types their password. There is no encryption or other security. It simply prevents an onlooker from being able to see the password as it is typed.
Setting the tab order for forms is the same as doing so for links. Keep in mind that the first time a user presses the tab key, it activates the address box. By default, the tab order follows the order in which elements appear on the page. You can assign tab order to text fields, password fields, checkboxes, radio buttons, text blocks, menus and buttons, as well as to links and client-side image maps.
You can disable an element with the disabled attribute. Keep in mind you will need a script that reenables the element based on user action you define. For example, you may want to disable the submit button to ensure the user has entered desired desired elsewhere in the form. A script would then reenable the form by testing that the user filled in required fields. Note that the element is grayed out when it is disabled.
Designers often want to display certain data in a form that was already obtained, however, they do not want users to be able to change the data. You can make elements read-only by using the readonly attribute.
HTML code in index.html | PHP code in process.php | |||
1. | <form action="process.php" method="get"> | 1. | <?php | |
2. | <select name="rating"> | 2. | //initialize a variable to the value of the form element named rating | |
3. | <option value="">Select a rating</option> | 3. | $rating = $_GET['rating']; | |
4. | <option value="1">The example is useless</option> | 4. | //define the function that will make a decision based on that value | |
5. | <option value="2">The example is useful</option> | 5. | function getRating($rating) { | |
6. | </select> | 6. | switch ($rating) { | |
7. | <input type="submit" value="Submit" /> | 7. | case 1: | |
8. | </form> | 8. | echo "The example is useless"; | |
9. | break; | |||
Action must be the name of your script. | 10. | case 2: | ||
Use autoglobal based on method to pass value: $_GET, $_POST or $_REQUEST (either get/post) |
11. | echo "The example is useful"; | ||
12. | break; | |||
The autoglobal must reference the element by name | 13. | default: | ||
Use the value of the option (or input) element for each case statement. Enclose alpha values in quotes. |
14. | echo "Please select a rating"; | ||
15. | } | |||
Use the variable name wherever the value needs to be passed. Here $_GET passes the value from form element named 'rating' to $rating variable. The value is then passed to the function call, which further passes the value to the function. The function passes it to the switch statement. The case statements evaluate the value and executes the applicable instructions. |
16. | } | ||
17. | //call the function so that it executes | |||
18. | getRating($rating); | |||
19. | ?> | |||
Make sure the function call is spelled exactly
the same as the name of the function. |
**Treat ALL names as case sensitive. | |||
| The opening div will close on line 31.. | |
If the first if returns true, it will execute the code between the { and }. It will then jump to line 30 and finish the remaining lines of code. | ||
If the first if returns false, it will skip lines 5-15 and execute the else between { and }. | ||
During execution of the else above, if the second if statement returns true, it will execute the code between { and }, then jump to line 30 and finish the remaining lines of code. | ||
If the second if returns false, it will skip lines 21-22 and execute the else between { and }, then finish the remaining lines of code. | ||
To curly or not to curly - that is the question. Though the { } is commonly referred to as function braces, most languages require them in flow control code blocks such as decision (conditionals) and iteration (looping) functions. In PHP, the { } is implicit for code blocks that only execute one line of code for such functions. If your decision or loop contains more than one line of code, you need to explicitly include them. I strongly urge you to include them whether they are needed or not because it makes the logic easier to follow, it will minimize the possibility of logic errors, and it will make it easier for you to transfer your knowledge to other languages. TIPS:
if (true) { |
||
index.html |
|
(a) addscript.php |
|
(b) displayscript.php |
|
bowlers.txt |
Madison, James Lewis, Joe Betts, Marian Magee, Ann Mouse, Minnie Cecil, David white, eric Mattatall, Billy khbkjn, jhbk betts, marian madison, james W, L gggggg, gggggg ddd, ddd jack, jack Ford, Jesse |