|
WebKeystone Example 10: Creating a guestbook
The Form
The Files
<FORM METHOD=POST ACTION="/wkstone/webkeystone.py">
<INPUT TYPE=HIDDEN NAME="UserID" VALUE="biz_webkeystone">
<INPUT TYPE=HIDDEN NAME="Profile" VALUE="examples/example10viewGuestbook.prof">
<CENTER>
<TABLE BORDER="1" CELLPADDING="5" CELLSPACING="0" WIDTH="90%" BGCOLOR="#FFFFCC" COLS="2">
<TR>
<TD>
<P>
<TABLE BORDER="0" WIDTH="90%">
<TR>
<TD ALIGN="LEFT" COLSPAN="2">
<P ALIGN="LEFT"><FONT SIZE="4" COLOR="#000000"><B>Enter the guestbook by clicking on the button below. Once there, you may sign the guestbook and view the guestbook log.</B></FONT>
<P>
<INPUT TYPE=SUBMIT VALUE="Enter Guestbook">
</TD>
</TR>
</TABLE>
</TD></TR></TABLE>
</CENTER>
</FORM>
# Example 10 Profile: examples/example10viewGuestbook.prof
# 02/05/1999
#
# Displays the guestbook.
#
# Open guest message file.
FF_READ 'examples/example10guests.txt'
guestMessages
RETURN 'examples/example10viewGuestbook.htm'
<!----------- MESSAGE DIVIDER --------------->
<I>
02/09/1999 10:46 AM
</I>
<BR>
<B>
This is the first post to the WebKeystone version of the guestbook.
<BR>
<BR>Michael
</B>
<BR>
<A HREF=""></A><BR>
Michael <<A HREF="mailto:michaelsaddress@olympus.net">michaelsaddress@olympus.net</A>><BR>
Port Hadlock, WA USA<BR>
<HR>
|
<HTML>
<HEAD>
<TITLE>Example 10 Guest Book</TITLE>
</HEAD>
<BODY BGCOLOR=FFFFFF>
<CENTER>
<H2>Example 10 Guest Book</H2>
</CENTER>
<CENTER>
<H3><A HREF="webkeystone.py?UserID=%(UserID)s&Profile=examples/example10addGuest.prof">Sign
the guestbook!</A></H3>
</CENTER>
<P>
<HR>
%(guestMessages)s
<P>
<CENTER>
| <A HREF="webkeystone.py?UserID=%(UserID)s&Profile=examples/example10viewGuestLog.prof">View Guestbook Logs</A>
| <A HREF="http://www.webkeystone.com/examples/example10.html">Return to Example 10</A> |
</CENTER>
</BODY>
</HTML>
|
# Example 10 profile: examples/example10addGuest.prof # 02/05/1999 # # Displays the form that visitors can fill out # to add their comments to your guestbook. # RETURN 'examples/example10addGuest.htm' |
<HTML>
<HEAD>
<TITLE>Add To Example 10 Guestbook</TITLE>
</HEAD>
<BODY BGCOLOR=FFFFFF>
<CENTER>
<H2>Add To Example 10 Guestbook</H2>
</CENTER>
<CENTER>
Please complete all fields marked <FONT COLOR=RED>*</FONT>.
</CENTER>
<FORM METHOD=POST ACTION="webkeystone.py">
<INPUT TYPE=HIDDEN NAME="UserID" VALUE="%(UserID)s">
<INPUT TYPE=HIDDEN NAME="Profile" VALUE="examples/example10saveGuest.prof">
<TABLE WIDTH=600 ALIGN=CENTER>
<TR>
<TD><B>Your Name:</B><FONT COLOR=RED>*</FONT></TD>
<TD>
<INPUT TYPE=TEXT NAME="Name.req" SIZE=30>
</TD>
</TR>
<TR>
<TD><B>Email address:</B><FONT COLOR=RED>*</FONT></TD>
<TD>
<INPUT TYPE=TEXT NAME="Email.req.vEmail" SIZE=40>
</TD>
</TR>
<TR>
<TD><B>URL (optional):</B></TD>
<TD>
<INPUT TYPE=TEXT NAME="URL" SIZE=50 VALUE="">
</TD>
</TR>
<TR>
<TD><B>City:</B><FONT COLOR=RED>*</FONT></TD>
<TD>
<INPUT TYPE=TEXT NAME="City.req" SIZE=15>
</TD>
</TR>
<TR>
<TD><B>State:</B><FONT COLOR=RED>*</FONT></TD>
<TD>
<INPUT TYPE=TEXT NAME="State.req" SIZE=3 MAXLENGTH=2>
</TD>
</TR>
<TR>
<TD><B>Country:</B><FONT COLOR=RED>*</FONT></TD>
<TD>
<INPUT TYPE=TEXT NAME="Country.req" SIZE=15 VALUE="USA">
</TD>
</TR>
<TR>
<TD VALIGN=TOP>
<B>Comments:</B><FONT COLOR=RED>*</FONT>
</TD>
<TD VALIGN=TOP>
<TEXTAREA NAME="Comments.req" COLS=40 ROWS=6 WRAP=YES></TEXTAREA>
</TD>
</TR>
<TR>
<TD COLSPAN=2>
<INPUT TYPE=SUBMIT VALUE="Add To Guestbook">
<INPUT TYPE=RESET VALUE="Reset Form">
</TD>
</TR>
</TABLE>
</FORM>
<CENTER>
<A HREF="webkeystone.py?UserID=%(UserID)s&Profile=examples/example10viewGuestbook.prof">View Guestbook</A>
<CENTER>
</BODY>
</HTML>
|
# Example 10 Profile: examples/example10saveGuest.prof
# 02/05/1999
#
# Saves the guest's information to the guestbook.
#
# Check for missing fields.
IF MissingReq
RETURN 'examples/example10missingFields.htm'
# Get the date value.
Date = f.time.strftime("%m/%d/%Y %I:%M %p", f.time.localtime(f.time.time()))
# Make sure all <HTML> tags are removed.
Comments = f.string.replace(Comments, '<', '<')
Comments = f.string.replace(Comments, '\n', '<BR>\n')
Name = f.string.replace(Name, '<', '<')
Email = f.string.replace(Email, '<', '<')
Country = f.string.replace(Country, '<', '<')
State = f.string.replace(State, '<', '<')
City = f.string.replace(City, '<', '<')
URL = f.string.replace(URL, '<', '<')
# Read in message template.
FF_READ 'examples/example10template.txt'
template
# Substitute using the template.
guestMessage = subs(template)
# Read in guestbook.
FF_READ 'examples/example10guests.txt'
guestMessages
# Write guestbook with new message.
FF_WRITE 'examples/example10guests.txt'
guestMessage
guestMessages
# Read in logfile
FF_READ 'examples/example10guestLog.txt'
guestLogs
logEntry = subs("%(Name)s - %(Email)s - %(Date)s\n")
# Write out logfile.
FF_WRITE 'examples/example10guestLog.txt'
guestLogs
logEntry
# View the guestbook.
CALL 'examples/example10viewGuestbook.prof'
|
<!----------- MESSAGE DIVIDER --------------->
<I>
%(Date)s
</I>
<BR>
<B>
%(Comments)s
</B>
<BR>
<A HREF="%(URL)s">%(URL)s</A><BR>
%(Name)s <<A HREF="mailto:%(Email)s">%(Email)s</A>><BR>
%(City)s, %(State)s %(Country)s<BR>
<HR>
|
# Example10 Profile: examples/example10viewGuestLog.prof
# 02/05/1999
#
# Displays the logs for the guestbook.
#
# Read log file.
FF_READ 'examples/example10guestLog.txt'
guestLogs
RETURN 'examples/example10viewGuestLog.htm'
|
<HTML>
<HEAD>
<TITLE>Example 10 Guestbook Logs</TITLE>
</HEAD>
<BODY BGCOLOR=FFFFFF>
<CENTER>
<H2>Example 10 Guestbook Logs</H2>
</CENTER>
<P>
<PRE>
%(guestLogs)s
</PRE>
<P>
<CENTER>
<A HREF="webkeystone.py?UserID=%(UserID)s&Profile=examples/example10viewGuestbook.prof">Back To Guestbook</A>
<CENTER>
</BODY>
</HTML>
|
Michael - michaelsaddress@olympus.net - 02/09/1999 10:46 AM |
missingTemplate = '<LI>%(1)s\n'
#---------------
<HTML>
<HEAD>
<TITLE>MISSING (or INVALID) FIELDS</TITLE>
</HEAD>
<BODY BGCOLOR=FFFFFF>
<FONT SIZE=4 COLOR=RED><B>MISSING (or INVALID) FIELDS</B></FONT>
<P>
<B>
Please go back and complete the following fields:
<UL>
%(MissingReq,missingTemplate)s
</UL>
</BODY>
</HTML>
|
| Previous Example | Next Example | Table of Contents |
Updated 2-August-99
|
|
|
|
|
| WebKeystone is a product of Townsend Software, Inc. ©1998 - 2001 Townsend Software, Inc. All rights reserved. |