Responsive web Framework

FUNCTIONALITY

Data storing

Procesar los datos provenientes de un formulario antes de almacenarlos en la base de datos

NOT AVAILABLE FOR TINY SCREENS

(minimum width: 480px)

More detailed information can be found in the documentation, since the storage of data is a little more complex than the deployment of information, and in this case is done by the CGI

Data adquisition

LTo recover data passed as a parameter, is quite simple, since the same utility provides the functionality. # Load cgi
our $cgi_this = new CGI;
# Retrieve cgi data
my $str_catalogID = $cgi_this->param('catalog');
my $str_name = $cgi_this->param('catalog_name');
my $str_desc = $cgi_this->param('catalog_desc');
# SiteUP parameters
my $char_action = $cgi_this->param('action');
# Get additional information
my $str_fromuri = $cgi_this->referer();
The first line registers an object called cgi, while the next three retrieve the form's own data. The penultimate line indicates that action type to be carried out, while the latter provides particular information to the CGI.

Validate

Although much of the information is validated via jQuery before being sent to the CGI, a second validation of information is made in order to verify the authenticity of the data and to avoid situations in which the javascript was disabled.

# Verify origin
die() unless ($bool_DEBUG || isSubstring($str_fromuri,$str_FULLDOMAIN));
# Verify data
push(@arr_errors,'id') unless (isID($str_catalogID));
isCollapsed($str_name,$str_desc);
IsChar($char_action);
The first line validates that the CGI has been called from a form in the same domain and that it is not in debug mode. The next line is a bit more complex, since first check that one of the parameters is actually an identifier and if not, adds it to a list of probable data errors. Following this, the following line eliminates double spaces as well as spaces at the beginning or end of the data, while the last line checks for a character.

Storage

Although much of the information is validated via jQuery before being sent to the CGI, a second validation of information is made in order to verify the authenticity of the data and to avoid situations in which the javascript was disabled.

# Proceed if no errors if (!@arr_errors) { dbLogin; if ($char_action eq 'c') { dbQuery("UPDATE ".dbPrefix."catalog SET name = '$str_name', description = '$str_desc' WHERE (id = '$str_catalogID') "); } dbLogout; } # Return to page print $cgi_this->redirect(-uri=>$str_fromuri); Very similar to the method of data recovery, except that an object has not been used to bind to the DB, the first lines execute the action in case of no errors, and finally it is redirected to the page from the Which action was requested.