Herman's maître d' says, "Me and the boys were trying to guess how you spell your name." Obviously, he has some grammar and sequencing problems. To help him out, you have two jobs to do.
Click on Herman's picture to run my lame program.
Be creative!!! Your fellow students will have an opportunity to do your madlib during the next class.
<!-- madlib3.html - calls madlib3.php from form
passing $name
and the fill-in words: $noun, $place, $number & $liquid -->
<html>
<head>
<title>Madlib with Functions & Arguments</title>
</head>
<body>
<p><a HREF=../index.html>Back to DFS's PHP Page</a></p>
<hr>
<h1 align="center">Madlib with Functions & Arguments</h1>
<p>Enter the information requested and click on "Do it!"</p>
<form method="POST" action="madlib3.php">
<table border>
<tr>
<td>Your Name</td><td><input type="text" name="name" value="" size="25"></td>
</tr>
<tr>
<td>A noun, e.g. cat</td><td><input type="text" name="noun" value="" size="25"></td>
</tr>
<tr>
<td>Your least favorite city</td><td><input type="text" name="place" value="" size="25"></td>
</tr>
<tr>
<td>A number</td><td><input type="text" name="number" value="" size="25"></td>
</tr>
<tr>
<td>A liquid</td><td><input type="text" name="liquid" value="" size="25"></td>
</tr>
<tr>
<td colspan="2" align=center><input type="submit" value="Do it!"><input type="reset"></td>
</tr>
</table>
</form>
</body>
</html>
<!-- madlib3.php - called from form in madlib3.html
receiving $name
and the fill-in words: $noun, $place, $number & $liquid -->
<html>
<head>
<title>Madlib with Functions & Arguments</title>
</head>
<body>
<p><a HREF=../index.html>Back to DFS's PHP Page</a></p>
<hr>
<h1 align="center">Madlib with Functions & Arguments</h1>
<?php
function greeting($name) {
echo "<p>Hello, $name.</p>\n";
}
function printlaw($noun, $place, $number, $liquid) {
echo "<table border=3 cellpadding=5>";
echo "<tr><th align=center>Your New Law</th></tr>\n";
echo "<tr><td>\n";
echo "<p>It will be unlawful to own a <font color=\"ff0000\">$noun</font><br>\n";
echo "or to carry a concealed <font color=\"ff0000\">$noun</font><br>\n";
echo "without a <font color=\"ff0000\">$noun</font> license.</p>\n";
echo "<p>The penalty for <font color=\"ff0000\">$noun</font>-carrying<br>\n";
echo "will be thirty days in <font color=\"ff0000\">$place</font><br>\n";
echo "or a fine of <font color=\"ff0000\">$number</font> dollars.</p>\n";
echo "<p>The penalty is double if the person<br>\n";
echo "is arrested while under the influence<br>\n";
echo "of <font color=\"ff0000\">$liquid</font>.</p>\n";
echo "</td></tr>";
echo "</table>\n";
}
function thanks($name) {
echo "<p>I hope you liked your new law, ";
echo $name . ".</p>\n";
echo "<p>Thank you for using my madlib.</p>\n";
}
// mainline
greeting($name);
printlaw($noun, $place, $number, $liquid);
thanks($name);
?>
</body>
</html>