|
Solution 6
Main | Review of Operators | Mathematical Functions | Practice 5 | Solution 5 | HTML Forms | PHP Forms | Practice 6 | Solution 6 | PHP and E-mail | Practice 7 | Solution 7
The solution to practice 6 is the following:
<h2>Simple Form Example</h2>
<? function show_form($first="",$last="") { ?>
<form action="simpleForm.php" method="post">
First Name:
<input type=text name=first value="<?echo $first?>">
<br>
Last Name:
<input type=text name=last value="<?echo $last?>">
<br>
<input type=submit>
</form>
<? }
if(!isset($first)) {
show_form();
}
else {
if(empty($first) or empty($last)) {
echo "You did not fill in all the
fields, try again<p>";
show_form($first,$last);
}
else {
echo "Thank you, $first $last";
}
}
?>
jfulton [at] member.fsf.org
|