Nes::Obj::multi_step - Secure Multi Step Form.
Send data over a script handler:
{: include ('{: * cfg_obj_top_dir :}/Nes/form/multi_step.nhtml', " script_handler => 'my_script_handler.pl', function_handler => 'my_function_handler', form_name => 'my_form_1', steps => {: # steps :} [ [ {: # step 1 :} { {: # field 1 for step 1 :} name => 'name', msg => 'The \"Name\"', type => 'text', size => 12, {: # check 4 min, 22 max, begins with a letter, alphanumeric :} check => '4,22,/^[a-zA-Z]\w*$/', }, { {: # field 2 for step 1 :} name => 'email', msg => 'Email Address', type => 'tex', size => 12, check => '8,40,/[\w-]+@([\w-]+\.)+[\w-]+/i', }, {: # more fields for stept 1 ... :} ], [ {: # step 2 :} { {: # field 1 for step 2 :} name => 'message', msg => 'Message', type => 'textarea', filter => 'yes_tag_B,yes_tag_BR,yes_tag_I', cols => 20, rows => 6, }, {: # more fields for step 2 ... :} ], {: # more steps ... :} ], " ) :}
Insert data directly to the database:
{: include ('{: * cfg_obj_top_dir :}/Nes/form/multi_step.nhtml', " to_database => 'INSERT', to_table => 'table', to_fields_assort => { name => 'name', }, {: # steps ... :} " ) :}
Update data directly to the database:
{: include ('{: * cfg_obj_top_dir :}/Nes/form/multi_step.nhtml', " to_database => 'UPDATE', to_table => 'table', to_where => '', to_limit => '', to_fields_assort => { name => 'name', }, {: # steps ... :} " ) :}
Create a form with one or more steps, with a captcha at the end. Data can be sent over a script handler or directly to the database.
For a better understanding of this object see live sample: http://nes.sourceforge.net or install 'nesblog' and see scripts and templates, with set_nes_site utility:
set_nes_site --from_exam=nesblog --to_exam=/full-path/root-www/nesblog
The script that contains the "function_handler"
Function that receives the form data. Receives the form fields in a hash reference. Must return none if successful, scalar if error or hash reference if fields errors. Sample:
sub function_handler { my $data = shift; my $error_fields = {}; my $error; ... if ( ! $data->{'name'} ) { $error_fields->{'name'} = 'Name is required'; } ... return $error_fields if $error_fields; return 'Error in DB' if $DB->{'error'}; return; }
See live sample: http://nes.sourceforge.net/miniblog/en/?action=register
Perl script to execute. Default none.
INSERT or UPDATE database.
Table name to insert or update.
WHERE clause in sql sentence in UPDATE mode.
LIMIT clause in sql sentence in UPDATE mode.
Correspondence from the fields of the database to form. If it begins with two points, is a function sql. Sample: date => ':NOW()'
Database name. Usually DB_... must be previously defined in its nes.cfg, multi_step take these defaults. But if you need to consult another database, can DB_... as parameters.
Not a good idea to include passwords in files html:
BAD: {: include ('{: * cfg_obj_top_dir :}/Nes/form/multi_step.nhtml', " to_database => 'INSERT', to_table => 'table', DB_base => 'basename', DB_user => 'baseuser', DB_pass => 'sakjuje7ey', ... " ) :}
Declare them as variables in their nes.cfg:
# primary database DB_base = basename DB_user = username DB_pass = password DB_driver = mysql DB_host = localhost DB_port = 3306 # alternative database form1_DB_base = otherbasename form1_DB_user = username form1_DB_pass = password form1_DB_driver = mysql form1_DB_host = localhost form1_DB_port = 3306
And so:
{: include ('{: * cfg_obj_top_dir :}/Nes/form/multi_step.nhtml', " to_database => 'INSERT', to_table => 'table', DB_base => '{: * cfg_form1_DB_base :}', DB_user => '{: * cfg_form1_DB_user :}', DB_pass => '{: * cfg_form1_DB_pass :}', ... " ) :}
Database user.
Database password.
Database driver.
Database host.
Database port.
Text to show if error data.
Text to show if success data.
Check referer.
Private key to crypt data.
1 show captcha, 0 not
Width table form.
Text or HTML to show before submit button.
Text or HTML to show after submit button.
Text to show in span tag error.
Time to expire form. Default 60 second for field. Time suffix: s: seconds, m: minutes h: hours d: days, M: months, y: years.
Tag name property of form.
Tag name property of captcha.
ascii.
Digit number captcha.
Captcha size.
Captcha noise level.
Character to the foreground
Character to the background
Time to expire captcha. Default '40s'. Time suffix: s: seconds, m: minutes h: hours d: days, M: months, y: years.
Text or HTML to show after captcha.
Text or HTML to show before captcha.
Attempts/minutes, if we reach attempts, wait the time shown in "minutes". Default is '10/5'
HTML Tag for the design of the captcha.
Out page. Default self.
Text to show in lengend tag.
Text to show in send button.
Text to show in captcha field.
Text or HTML to show in captcha. Default "Finally, enter the security code below."
Text or HTML to show if captcha error.
Text or HTML to show if form error.
Tag id property of form.
Tag class property of form.
Action property form.
Template errors.
Template for options.
Text or HTML to show if field error.
Tag name property of field.
Tag id property of field.
Tag class property of field.
Tag value property of field.
Tag size property of field.
Others tag property of field. Sample: property => 'READONLY'
Tag type of field: text, textarea, select, hidden.
Tag cols property in textarea.
Tag rows property in textarea.
Text to show for the field.
Text or HTML to show before field.
Text or HTML to show after field.
Verify field in format: 'min,max,regexp'. Sample: '0,70,/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/i' is optional (0 min length) 70 max length, and email regular expression.
Text or HTML to show if check error.
Filter field value by Nes filter options, no_html, yes_html, etc.
Template to include in field.
Not support "multiple select".
Skriptke: Enrique Castañón
Version 1.03 April 2010
Copyright (c) Enrique F. Castanon Barbero. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms and conditions as GNU Public License (GPL).
This means that you can, at your option, redistribute it and/or modify it under either the terms the GNU Public License (GPL), or under the Perl Artistic License.
See http://dev.perl.org/licenses/
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Use of this software in any way or in any form, source or binary, is not allowed in any country which prohibits disclaimers of any implied warranties of merchantability or fitness for a particular purpose or any disclaimers of a similar nature.
IN NO EVENT SHALL I BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION (INCLUDING, BUT NOT LIMITED TO, LOST PROFITS) EVEN IF I HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
Nes, Nes::Tutorial, Nes::Singleton, Nes::nes.cfg, Sample to use Nes; http://nes.sourceforge.net/
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Castañón'. Assuming UTF-8
To install Nes, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Nes
CPAN shell
perl -MCPAN -e shell install Nes
For more information on module installation, please visit the detailed CPAN module installation guide.