| #include <stdio.h>
|
| #include <stdlib.h>
|
| #include <dcmicro/htmlpp/htmlpp.h>
|
|
|
| int main( void )
|
| {
|
| htmlCgi server( cin ) ;
|
| htmlPage page ;
|
|
|
| htmlForm form( "/cgi-bin/prepop" );
|
|
|
| // Set up input areas for last name, first name,
|
| // and email address. Allow up to 20 characters
|
| // for the names, and 30 characters for the email.
|
| // Note that we're specifically assigning the
|
| // 'email' field to a non-empty value.
|
| form << "Last Name: "
|
| << htmlInputText( "lname", 20 )
|
| << htmlBreak() ;
|
|
|
| form << "First Name: "
|
| << htmlInputText( "fname", 20 )
|
| << htmlBreak() ;
|
|
|
| form << "Email address: "
|
| << htmlInputText( "email", "XXX", 30 )
|
| << htmlBreak() ;
|
|
|
| // Add a submit button with a custom label
|
| form << htmlCenter( htmlInputSubmit("Press to continue") );
|
| page << form ;
|
|
|
| // Create data elements with names matching the form
|
| // fields of interest. These values will replace empty
|
| // values with the same name during output. In this
|
| // example we're assigning the values directly. In
|
| // practice, one would typically obtain the values from
|
| // a database or other source such as a CGI list from
|
| // another form.
|
| server( "lname" ) = "Smith" ;
|
| server( "fname" ) = "John" ;
|
|
|
| // Note that since the input field named 'email' already
|
| // has a value, the following line of code has no effect.
|
| server( "email" ) = "johnsmith@xyz.com" ;
|
|
|
| // Output the page containing the form, performing
|
| // the value replacements for empty form fields that
|
| // have matching names in the server's CGI list.
|
| server << page ;
|
| return 0 ;
|
| }
|
|
|
| |