1.Hello.prg This is a basic FoxPro CGI program. It is very simple, but it is
a network program and can be run over internet.. SET PROCEDURE TO htmlpath+"htmllib.fxp"
&&== Load htmllib library
=HtmlBegin()
&&== Html File Header
=HtmlTitle("This is a my first
FoxPro Net Program")
&&== Title of homepage
=Htmlhtmlfcolor("LightBlue")
&&-- Set Font color
=HtmlSentence("Hi, Glad to see
you !")
&&== Write a senterce in homepage
=HtmlEnd()
&&== Html end
return
Type in: http://Your IP/cgi-shl/foxcgi.exe/hello.prg
to try it. Or run it on my server: http://202.114.6.48/cgi-shl/foxcgi.exe/hello.prg?
2.Queryin.prg This program show how to get a user's query input, then return it
to user. SET PROCEDURE TO htmlpath+"htmllib.fxp"
&&== Load htmllib library
query=htmlquery
&&-- Get User's input of query
=HtmlBegin()
&&-- Html File Header
=Htmlhtmlfcolor("LightBlue")
&&-- Set Font color
=HtmlTitle("This is a Demo Page")
&&-- Title of homepage
=HtmlSentence("Hi, I have heard
from you !")
&&-- Write a senterce in homepage
=HtmlLine()
&&-- Insert a separate line
=HtmlSentence("Your query input
is: "+query)
&&-- Return user's input
=HtmlEnd()
return
&&== Html end
Type in: http://Your IP/cgi-shl/foxcgi.exe/queryin.prg?your_query
to try it. Or run it on my server: http://202.114.6.48/cgi-shl/foxcgi.exe/Queryin.prg?your
query
3.Formin.prg This program show how to get user's form input, then return them
to user. SET PROCEDURE TO htmlpath+"htmllib.fxp"
&&-- Load htmllib library
userip=htmlclientip
&&-- User's IP address
number=htmlparlen
&&-- Input parameters number of Form
parname1=htmlin(1,1)
&&-- Name of first input parameters
parvalue1=htmlin(1,2)
&&-- value of first input parameters
parname2=htmlin(2,1)
&&-- Name of first input parameters
parvalue2=htmlin(2,2)
&&-- value of first input parameters
&&..........
=HtmlBegin()
&&-- File Header
=Htmlhtmlbcolor("GREY")
&&-- Backgroundcolor of homepage
=HtmlTitle("This is a Demo Page")
&&-- Title of homepage
=Htmlhtmlfcolor("LightRed")
&&-- Set Font color
=Htmlalign("Center")
&&-- Set object align
=HtmlFontSize("18")
&&-- Set Font Size
=HtmlSentence("Hi, I have heard
from you !") &&-- Write a senterce in homepage
=HtmlLine()
&&-- Insert a separate line
=Htmlalign("Left")
&&-- Set object align
=HtmlFontSize("12")
&&-- Set Font Size
=Htmlhtmlfcolor("Black")
&&-- Set Font color
=HtmlSentence("Your IP is: "+userip)
&&-- Return user's input
=HtmlSentence("Your Form
input is below:")
FOR I=1 TO NUMBER
=HtmlSentence(htmlin(i,1)+"="+htmlin(i,2))
ENDFOR
=HtmlLine()
=Htmlalign("Center")
=HtmlSentence(DTOC(DATE( )))
=HtmlEnd()
&&== Html end
return
The form based CGI program is work with a form, below is a example:
Edit this page and change IP adderss in submit button to your IP address,
then click submit to try. Or click submit button at this time to try it
on my server.
4.Libdemo.prg This program show how to use HtmlLib functions to design FoxPro
CGI program. SET PROCEDURE TO htmlpath+"htmllib.fxp"
=HtmlBegin()
=Htmlbcolor("White")
=HtmlTitle("HtmlLib Function List")
=Htmlfcolor("Black")
=Htmlalign("Left")
=HtmlFontSize("12")
=HtmlSentence("1.Font size Function
demo")
&& show different font size
=HtmlFontSize("8")
=HtmlWords("8")
=HtmlFontSize("12")
=HtmlWords("12")
=HtmlFontSize("18")
=HtmlWords("18")
=HtmlFontSize("36")
=HtmlSentence("36")
=HtmlFontSize("12")
=HtmlSentence("2.Font Color Function
demo")
&& show different font color
=Htmlfcolor("Red")
=HtmlWords("Red")
=Htmlfcolor("Green")
=HtmlWords("Green")
=HtmlFcolor("Blue")
=HtmlWords("Blue")
=HtmlFcolor("Yellow")
=HtmlSentence("Yellow")
=HtmlFcolor("Black")
=HtmlSentence("3.Object align Function
demo")
&& show different object align
=Htmlalign("Left")
=HtmlWords("Left")
=Htmlalign("Center")
=HtmlSentence("Center")
=Htmlalign("Left")
=HtmlSentence("3.Object insert
function demo")
&& show different object insert function
=HtmlWords("InsertWords")
=HtmlLinkWords("InsertLinkWords","http://www.infoseek.com")
=Htmlreturn()
=Htmlsentence("Insert sentence:
How are you !")
=Htmllinksentence("Insert linked
sentence:Press here to visit Yahoo !","http://www.yahoo.com")
=Htmlline()
=HtmlGraph("http://202.114.6.48/ask.gif")
=HtmlLinkGraph("http://202.114.6.48/search.gif","http://www.yahoo.com")
=Htmlreturn()
=HtmlSentence("4.Table insert function
demo") && show Table insert function
Dimension aa(2,4)
aa(1,1)="Name"
aa(1,2)="Address"
aa(1,3)="Phone"
aa(2,1)="Lingsong He"
aa(2,2)="China"
aa(2,3)="87542079"
=HtmlArrayTable(aa,2,3)
use htmlpath+"datas\articles.dbf"
=HtmlDbfTable()
use
return
Type in: http://Your IP/cgi-shl/foxcgi.exe/Libdem.prg
to try it. Or run it on my server: http://202.114.6.48/cgi-shl/foxcgi.exe/Libdemo.prg?
4.Search.prg This program show how to design a simple search engine program by
FoxNet. SET PROCEDURE TO htmlpath+"htmllib.fxp"
keywords=htmlin(1,2)
&&------ Get user's search words
=HtmlBegin()
=HtmlTitle("Internet HotFiles Search
Result")
=Htmlfcolor("LightRed")
=Htmlalign("Center")
=HtmlFontSize("24")
=HtmlSentence("Internet HotFiles
Search Result")
=HtmlLine()
=HtmlFontSize("12")
=Htmlalign("Left")
=Htmlfcolor("Black")
use htmlpath+"datas\search.dbf"
&&------ Open hotfile database
SET filter to ATC(keywords,search.content)>0
&&----- Find qualified record
n=1
DO WHILE EOF()=.F.
=HtmlLinksentence(str(n)+">"+search.name,search.url)
&&---- Return search result to user
m.s=search.content
=Htmlsentence(m.s)
SKIP 1
n=n+1
ENDDO
use
=HtmlLine()
=HtmlSentence(DTOC(DATE( )))
=HtmlEnd()
return
This program work with a form below. Change IP adderss in submit
button to your IP address, then click submit to try. Or click submit button
at this time to try it on my server.