今天讲一下用怎么创建FORM表单,我将在下面讲的全部都用object-oriented style来
举列子。
如:
- #!/usr/bin/perl -w
- use CGI;
- use strict;
- my $time = localtime;
- my $system = `uname -n`;
- my $user = `whoami`;
- my $path = `pwd`;
- my $q = CGI->new;
- $q->header(-charset=>'utf-8'),
- $q->start_html(-title=>'Welcome',-style=>{'src'=>'../manual/style/css/a.css'}),
- $q->start_table({-align=>'center',-width=>'60%'}),
- $q->start_Tr,
- $q->start_td({-align=>'left'}),
- "SYSTEM TIME : $time",$q->p,
- "SYSTEM : $system",$q->p,
- "SYSTEM USER : $user",$q->p,
- "SYSTEM PATH : $path",
- $q->hr,
- $q->start_form(-name=>'form_field',-method=>'post',-action=>'#'),
- "Username : ",$q->textfield(-name=>'user',-override=>1,-size=>30,-maxlength=>80),$q->p,
- "Password : ",$q->password_field(-name=>'password',-override=>1,-size=>32,-maxlength=>80),$q->p,
- "Email : ",$q->textfield(-name=>'email',-override=>1,-size=>30,-maxlength=>80),$q->p,
- "Upload File : ",$q->filefield(-name=>'upload',-default=>'starting value',-size=>50,-maxlength=>80),$q->p,
- $q->submit(-name=>'submit',-value=>'提交'),
- $q->reset(-name=>'reset',-value=>'重置'),
- $q->end_form,
- $q->end_td,
- $q->end_Tr,
- $q->end_table,
- $q->hr;
- "Your name is ",$q->em($q->param('user')),$q->p,
- "Your password is ",$q->em($q->param('password')),$q->p,
- "Your email is ",$q->em($q->param('email')),$q->p,
- "Your upload file is ",$q->em($q->param('upload')),$q->p,
- $q->end_html;
我这里加入了css样式,为了好看,嘿嘿!!