Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > cd38b09e3cb8d6c675b02d30393e68af > files > 55

kaya-doc-0.5.2-8.fc14.noarch.rpm

cgi helloweb2;

import Regex;
import CGI;

Void PreContent()
{
    content("<html><head><title>Hello!</title>
             </head><body>");
}

Void Default()
{
    helloForm();
}

Void helloForm()
{
    content(formHandler(OnHello,0)+
	    "What is your name? "+
	    textBox("name")+
	    submit("Say Hello")+
	    closeForm());
}

Void OnHello(Int dummy)
{
    name = incomingValue("name",DataPost);
    // replace is a useful detainting function, but can't...
    replace("<","&lt;",name,[Global]);
    replace("&","&amp;",name,[Global]);
    content("<p>Hello "+name+"!</p>");
    helloForm();
}

Void PostContent()
{
    content("</body></html>");
}