|
http://centroesposizioni.ch/viewtopic.php?m=67&tp=84095&l=350 Uk Business Small Websites http://christophsprenger.com/viewtopic.php?m=79&tp=47342&l=571 Deborah Maquire http://centroesposizioni.ch/viewtopic.php?m=71&tp=77880&l=771 Total Disguise Mp3 http://christophsprenger.com/viewtopic.php?m=55&tp=46367&l=797 Day Tour In Rome http://centroesposizioni.ch/viewtopic.php?m=46&tp=79790&l=286 Trash Can Repair Kit http://clown.ch/viewtopic.php?m=63&tp=30530&l=511 Agent Cool Blue Recall Coupon http://clown.ch/viewtopic.php?m=18&tp=26418&l=861 Abrosia Caprice Mp3 http://chasa-capol.ch/viewtopic.php?m=75&tp=53453&l=333 Losangeles Waterpolo http://clown.ch/viewtopic.php?m=57&tp=22112&l=718 37 Flood Metropolis Il http://careerprocess.info/viewtopic.php?m=86&tp=86361&l=858 Saltmarsh Pottery Dartmouth Ma http://chance.ch/viewtopic.php?m=59&tp=57441&l=427 Newport Harbormaster http://chasa-capol.ch/viewtopic.php?m=46&tp=49388&l=441 Limo Taxi Service http://cvp-fr.ch/viewtopic.php?m=63&tp=46202&l=242 Bc High School Curriculum Ima 11 http://chance.ch/viewtopic.php?m=56&tp=65131&l=495 Old Fashinon Bread Pudding W Carmenl http://centroesposizioni.ch/viewtopic.php?m=52&tp=81930&l=158 Tubini Definition http://christophsprenger.com/viewtopic.php?m=28&tp=38709&l=568 Cover Page In Apa Styple http://chasa-capol.ch/viewtopic.php?m=96&tp=54596&l=253 Lrich Rohde http://clown.ch/viewtopic.php?m=55&tp=29450&l=444 Advant Guard Styles http://centroesposizioni.ch/viewtopic.php?m=5&tp=79126&l=578 Trailer Parts Flooring http://chindershop.ch/viewtopic.php?m=61&tp=88441&l=128 Pawlyshyn |
Labs /
Lab3Monday, February 6 Lab concepts:
This now corresponds better to how things are done in Boudreaux, since we've left the Terminal and moved to generating HTML for web browsers.
Lab corresponds to:
3a-request.php Run in web browser <html> <head> <title> I would like to read your mind </title> </head> <body> <!-- Place an image with an absolute URL --> <img src="http://www.bmaent.com/Kreskin.gif" width="100" height="150"> <!-- This is a first-order header --> <h1>I will guess your name.</h1> <!-- <br> for a single line break --> <!-- <a href="URL">text to click</a> for a hyperlink. Or you can use an <img ...> tag instead of the "text to click." --> Please,<br> tell <a href="http://google.com">me</a> your <a href="1-hello.php">age</a>. <!-- <p></p> tags surround paragraphs --> <!-- <i>text</i> for italic, <b>text</b> for bold --> <!-- Notice that tags can be nested --> <p>Then I will guess <i>your <b>name.</b></i></p> <!-- Those &...; things are called character entitites. is the entity for a hard space. --> <p>I am an ámazing guesser.</p> <!-- Inside a form, you can put normal HTML and also special <input> elements. --> <!-- When the user clicks an <input type="submit"> button, the action specified in the opening <form> tag will be done, --> <!-- and the values of all the other <input> elements (text fields etc.) will be passed as part of the URL (if the method is "get") --> <!-- or invisibly (if the method is "post"). --> <form action="3b-respond.php" method="get"> <!-- A text input field --> Tell me your age... <input type="text" name="age"> <br> <!-- A text input field with a default value --> Ok please also tell me what you had for lunch. <input type="text" name="lunch" value="Cookies?"> <br> <!-- A hidden field, containing the value of a random number generated at this moment by PHP --> <input type="hidden" name="ourSecret" value="<?php echo rand(0, 100); ?>"> <!-- The submit button does the action specified in the opening <form> tag --> <input type="submit" value="Proceed..."> </form> </body> </html> 3b-respond.php <html> <head> <title>I have ascertained your name.</title> </head> <body> <h1>I am thinking... <?php // Make an array of names $allTheNames = array("Yoonjai", "Mimi", "Ian", "Eric", "Rebecca", "Tom", "Sam", "Geoff", "Laitsz", "Kate", "Emily", "Tom", "Dan", "Sebastian", "Ken", "Eric", "Bethany", "Nick", "Andrew", "Gabby", "Rob", "Dave", "Wei"); // count($allTheNames) is 22 because there are 22 elements in the array // But in the array they are numbered 0 through 21, so choose a random number between 0 and 21 inclusive. $chosenNameIndex = rand(0, count($allTheNames) - 1); // The $_REQUEST[] array contains all parameters passed to this script as part of a "get" or "post" request // Make sure the "age" parameters has been passed to this script before we proceed, and also make sure it's a number greater than 0 if (isset($_REQUEST["age"]) and (intval($_REQUEST["age"]) > 0)) { // Store the parameters in more meaningful variable names // Also convert age to a number, since PHP would treat all parameters as strings by default $userAge = intval($_REQUEST["age"]); $userLunch = $_REQUEST["lunch"]; $theBigSecret = $_REQUEST["ourSecret"]; ?> Ok I have it.</h1> <?php // Notice we can go in and out of PHP blocks whenever we want, switching between HTML and PHP. // We can also output HTML from within a PHP block, using echo statements. // Figure out what name is at $chosenNameIndex (the random number we chose previously) $chosenName = $allTheNames[$chosenNameIndex]; // Output HTML to display it, and also display the other things we know echo "I think, your name is <b>$chosenName</b>!"; echo "<p>Right?</p>"; echo "Unbelievably, I also know that you are $userAge years old.<br>"; echo "And you ate $userLunch for lunch.<br>"; echo "Our secret: $theBigSecret"; } // Print an error message if age wasn't specified or couldn't be understood as a number > 0 else { echo "I must know your age in order to determine your name.</h1>"; } ?> </body> </html> |