[resolved] Avoid Double Validation of the “Prcent Button” Form?


For example yes.

 There’s a lot more we can do:

 1- Sending the form :

 $_SESSION[‘form_name’] = customer input;$_SESSION[‘form_name’] = customer input;$_SESSION[‘form_name’][‘name’][‘type’] = ALPHA;$_SESSION[‘form_name’][‘name’][‘mandatory’] = true;$_SESSION[‘client input’][‘name’][‘min-length’] = 5;$_SESSION[‘client input’][‘name’][‘max-length’] = 25;

 $_SESSION[‘customer input’][‘tel’][‘type’] = TEL;

$_SESSION[‘customer input’][‘tel’][‘mandatory’] = false;

 $_SESSION[‘customer_entry’][‘business_code’][‘type’] = LIST;

$_SESSION[‘customer_entry’][‘business_code’][‘mandatory’] = true;

$_SESSION[‘customer_entry’][‘business_code’][‘values’] = $business_code_tables;

 …

 2- Receipt of the form :

 Check that $_SESSION[‘form_name’] exists and retrieve its value -> $form_name.

If does not exist, error -> previous step.

 Delete the form from the session: unset( $_SESSION[‘form_name’] );

 Retrieve the table of form fields: $formFields = $_SESSION [‘customer input’];

 Check the fields received against what is expected.

Is this field mandatory.

Depending on the type, is the data received correct…

 You see the principle.

 A whole bunch of checks can be automated.

 I’ve used tables for simplicity, but a good idea would be to use objects. With objects, it is simpler to call the function (method) of verification that goes well

 It’s up to you!

—————————————————————————————————————————————

Leave the state in the bathroom where you found him.

You May Also Like