Recording data submitted by the form generator

Jump to navigation Jump to search

Once A form has been generated and data submitted through it dynamically. The management of the submitted data is done following the below steps :

Step 1 : Check for form errors

<syntaxhighlight lang="PHP"> /* Form errors management */ if(isset($_SESSION['add_item_form'])){ $form=unserialize($_SESSION['add_item_form']); } else{ $form=new html_form; } $form->check_form_data(); //* End Form errors management if($form->field_error_found){ $data_not_sent=true; include('view/itemadmin.php'); } else{ (...) </syntaxhighlight>

Step 2 : Secure data

Submitted data can be secured using the method secure of the html_form class

<syntaxhighlight lang="PHP"> $form->secure_data(); </syntaxhighlight>

Step 3 : Recording data

Once data has been secured, every form input can be collected in its variable equivalent automatically :

i.e : <syntaxhighlight lang="PHP"> $_POST['name']

is now available as

$name </syntaxhighlight>