Lesson 7 | Processing States using Perl CGI |
Objective | More with the state-machine Guestbook |
<!-- $filename --> <table> <tr><td width=20 height=30> <tr><td><td> <h3>Error:</h3> <p>$error <form action="$callback" method=POST> <p> <input type=submit value=" Continue "> <input type=hidden name=name value=$name> <input type=hidden name=wherefor value=$wherefor> <input type=hidden name=message value=$message> <input type=hidden name=state value=edit> </form> <tr><td height=30> </table>
<!-- $filename --> <table> <!-- for medicinal purposes --> <tr> <td width=20 height=20> <tr> <td width=20 height=20> <td width=300> <form action="$callback" method=POST> <h3>Please write in my Guestbook:</h3> <p>Your Name: <br><input type=text name=name value="$name" size=40> <p>Where are you from? <br><input type=text name=wherefor value="$wherefor" size=40> <p>Say something cool: <br> <textarea cols=40 rows=10 name=message wrap=hard>$message</textarea> <p> <input type=submit value=" Make it so! "> <input type=reset value=" Reset the form "> <input type=hidden name=state value=validate> </form> </table>
<!-- $filename --> <html> <title>$title</title> <body link="#6666CC" vlink="#6666CC" alink="#CC6666"> <img src=guestbook.gif width=330 height=55> <br clear=all>
<!-- $filename --> <!-- the table is just here for aesthetic reasons i use it to give the page some air --> <table> <tr><td width=20 height=30> <tr><td><td> <a href="$callback?state=create"><img src=create.gif width=115 height=45 border=0 alt="Create an entry"></a> <tr><td height=30> <tr><td><td> <a href="$callback?state=view"><img src=view.gif width=135 height=45 border=0 alt="View recent entries"></a> <tr><td height=30> </table>
<!-- $filename --> <table> <tr><td height=35> <tr><td width=20><td width=300> <h3>Your entry has been saved.</h3> <form method=POST action="$callback"> <input type=hidden name=state value=view> <input type=submit value=" Continue "> </form> <tr><td height=35> </table>
<!-- $filename --> <h3>Here's your entry for the Guestbook:</h3> $$viewrec.htmlp <table> <tr><td width=20><td width=400><hr noshade size=3> <tr><td width=20><td width=400> <form method=POST action="$callback"> <input type=hidden name=name value="$name"> <input type=hidden name=wherefor value="$wherefor"> <input type=hidden name=message value="$message"> <input type=hidden name=state value=save> <p> If this entry looks good, <br> <input type=submit value=" Save it. "> </form> <form method=POST action="$callback"> <input type=hidden name=name value="$name"> <input type=hidden name=wherefor value="$wherefor"> <input type=hidden name=message value="$message"> <input type=hidden name=state value=edit> <p> If you need to change something, <br> <input type=submit value=" Try again. "> </form> </table>
<!-- $filename --> <table> <tr><td width=20 height=30> <tr><td><td> <table> <tr><td><td> <p> Go back to the <a href="$callback?state=first"> Main Menu</a> <tr><td><td> <p> Put in your own <a href="$callback?state=create"> New Entry</a> <tr><td height=30> </table> <h2>Recent Guestbook Entries</h2> </table> ${ entries() }
<table> <tr><td width=20><td width=400><hr noshade size=3> <tr><td><td> <p> Go back to the <a href="$callback?state=first"> Main Menu</a> <tr><td><td> <p> Put in your own <a href="$callback?state=create"> New Entry</a> <tr><td height=30> </table>
<!-- $filename --> <table> <tr><td width=20><td width=400><hr noshade size=3> <tr><td width=20><td width=400> <p> <b>$name</b> <br><em>From $wherefor</em> <br>Date: $date <blockquote> $message </blockquote> </table>
sub first { htmlhead("My Guestbook!"); htmlp("initial.htmlp"); htmlfoot(); }
<!-- $filename --> <html> <title>$title</title> <body > <img src=guestbook.gif width=330 height=55> <br clear=all>
<!-- $filename --> <hr noshade size=1 width=300 align=left> <small> Based on the Magic Guestbook by <a href="http://www.weinman.com/wew/">Bill</a> <a href="http://www.weinman.com/">Weinman</a> </small> <br> <tt>[<a href="http://www.weinman.com/wew/">Home</a>]</tt> <tt>[<a href="http://www.cgibook.com/">CGI Book</a>]</tt> <tt>[<a href="http://www.perlbook.com/">Perl Book</a>]</tt> </body> </html>
sub view { htmlhead("My Guestbook: $state"); htmlp("view.htmlp"); htmlfoot(); }
<!-- $filename --> <p> Go back to the <a href="$callback?state=first"> Main Menu</a> <p> Put in your own <a href="$callback?state=create"> New Entry</a> <h2>Recent Guestbook Entries</h2> ${ entries() } <p> Go back to the <a href="$callback?state=first"> Main Menu</a> <p> Put in your own <a href="$callback?state=create"> New Entry</a>
${ entries() }