Page 317 - Beginning PHP 5.3
P. 317
Chapter 10: Preserving State With Query Strings
< !DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd” >
< html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en” >
< head >
< title > Remembering user information with cookies < /title >
< link rel=”stylesheet” type=”text/css” href=”common.css” / >
< /head >
< body >
< h2 > Remembering user information with cookies < /h2 >
< ?php if ( $firstName or $location ) { ? >
< p > Hi, < ?php echo $firstName ? $firstName : “visitor” ? > < ?php echo
$location ? “ in $location” : “” ? > ! < /p >
< p > Here’s a little nursery rhyme I know: < /p >
< p > < em > Hey diddle diddle, < br / >
The cat played the fiddle, < br / >
The cow jumped over the moon. < br / >
The little dog laughed to see such sport, < br / >
And the dish ran away with the spoon. < /em > < /p >
< p > < a href=”remember_me.php?action=forget” > Forget about me! < /a > < /p >
< ?php } else { ? >
< form action=”remember_me.php” method=”post” >
< div style=”width: 30em;” >
< label for=”firstName” > What’s your first name? < /label >
< input type=”text” name=”firstName” id=”firstName” value=”” / >
< label for=”location” > Where do you live? < /label >
< input type=”text” name=”location” id=”location” value=”” / >
< div style=”clear: both;” >
< input type=”submit” name=”sendInfo” value=”Send Info” / >
< /div >
< /div >
< /form >
< ?php } ? >
< ?php
}
? >
< /body >
< /html >
279
9/21/09 9:05:11 AM
c10.indd 279
c10.indd 279 9/21/09 9:05:11 AM