SUBROUTINE GETCOOKIE
* Display a simple form, requesting entry of a name in single EditBox.
* Set the initial value of the EditBox from a previously saved cookie.
* Include the RealWeb definitions
INCLUDE #RW.INCLUDE.DEFS FROM /SYSFILES/REALWEB,BP
EQU AM TO CHAR(254)
* Retrieve the cookie, if any.
COOKIEVALUE = ""
CALL RW_GET_COOKIE("CookieForm", COOKIEVALUE)
* Start the HTML page.
CALL RW_START_HTML_PAGE("Cookie Form", "", "", "", "")
CALL RW_START_PARA("", "")
IF COOKIEVALUE = "" THEN
CALL RW_PUT("Please enter your name in the box, then click the Go button")
END ELSE
CALL RW_PUT("Your name cannot contain numbers: please re-enter.")
END
CALL RW_END_PARA
CALL RW_START_HTML_FORM("SETCOOKIE", "SETCOOKIE", CLASS)
* Move the cookie value to the third attribute for use in the
* aClass parameter of the RW_EDIT_BOX subroutine.
COOKIEVALUE = AM:AM:COOKIEVALUE
CALL RW_EDIT_BOX("NAME", 30, COOKIEVALUE)
CALL RW_SUBMIT_BUTTON("GO", "")
CALL RW_END_FORM
* Complete the page.
CALL RW_END_PAGE
RETURN
The screen dump shows the result of submitting invalid data:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<META NAME="Generator" CONTENT="Reality">
<TITLE>Cookie Form</TITLE>
</HEAD>
<BODY>
<P>
Your name cannot contain numbers: please re-enter.
</P>
<FORM ACTION="SETCOOKIE" NAME="SETCOOKIE" METHOD="POST">
<INPUT VALUE="Paul2" NAME="NAME" SIZE="30" TYPE="TEXT">
<INPUT TYPE="submit" VALUE="GO">
</FORM>
</BODY>
</HTML>