Harbour Marine Supply

Contact

The program behind this page
0010 ! contact.nvx - a form: shown, checked, acted on once, and answered on a page of its own.
0020 IF %REQ'Method$="POST" THEN GOTO 0100
0030 IF %REQ'Query$("sent")="1" THEN %RES'Data("sent")=1; %RES'Data("name")=%SESSION'Get$("contact_name"); GOTO 0200
0040 GOTO 0200
0100 NAME$=STP(%REQ'Form$("name")); EMAIL$=STP(%REQ'Form$("email")); TEXT$=STP(%REQ'Form$("message"))
0110 IF NAME$="" THEN %RES'Data("errors.1")="Tell us your name."
0120 IF POS("@"=EMAIL$)<2 OR POS("."=EMAIL$)=0 OR POS(" "=EMAIL$) THEN %RES'Data("errors.2")="That does not look like an email address."
0130 IF LEN(TEXT$)<10 THEN %RES'Data("errors.3")="Write at least a line."
0140 IF NAME$<>"" AND POS("@"=EMAIL$)>1 AND POS("."=EMAIL$)>0 AND POS(" "=EMAIL$)=0 AND LEN(TEXT$)>=10 THEN GOTO 0300
0150 %RES'Status=422; %RES'Data("name")=NAME$; %RES'Data("email")=EMAIL$; %RES'Data("message")=TEXT$
0200 %RES'Data("once")=%REQ'OnceField$
0210 CALL "private/programs/source.nvx","public/contact.nvx",S$; %RES'Data("source")=S$
0220 %RES'Render("contact.html"); END
0300 ! the message is kept in the site's data; then the visitor is sent to a page that can be reloaded safely
0310 SERIAL "data/messages.txt",ERR=*NEXT
0320 OPEN LOCK (1)"data/messages.txt"
0330 READ (1,END=0340)L$; GOTO 0330
0340 PRINT (1)NAME$+" <"+EMAIL$+"> "+TEXT$; CLOSE (1)
0350 %SESSION'Set("contact_name",NAME$)
0360 %RES'Redirect("/contact?sent=1",303)