The generated form already has lots of client side form validations, including logic and condition checking; it also comes with backend and form admin panel. It's a fully functional out-of-box web form solution, and it just works.
There are still cases you want more control with all the good parts of the form, to fully control the frontend and your backend. Here are some tips on how you can customize it for your needs.
Download customized backend project
In order the form frontend can "talk" to your backend, the backend has to response a JSON telling the form with server side validation result.
<?php // do server side validation logic // ...... // then response the result in JSON $result = array( 'validated' => true, 'fieldValues' => $form ); header('Content-Type: text/html'); echo json_encode($result);The full source code of the backend login.php:
<?php /** * JQuery form backend customization demo script */ session_start(); define( 'DEMO_EMAIL', 'demo@demo.com' ); define( 'DEMO_PASSWORD', 'demo123' ); $_SESSION['user.authenciated'] = false; // main # --------------------------------------- checkLogin(); # --------------------------------------- function checkLogin(){ // convert field names for easy coding $fieldMaps = array( 'f2' => 'email', 'f5' => 'password' ); $form = convertPostValues($fieldMaps,false); $loginOk = DEMO_EMAIL == $form['email'] && DEMO_PASSWORD == $form['password']; if( !$loginOk ){ echo "Failed to login"; exit; } // send json back to Ajax response handler $result = array( 'validated' => true, 'fieldValues' => $form ); header('Content-Type: text/html'); echo json_encode($result); $_SESSION['user.authenciated'] = true; } function convertPostValues( $fieldMaps, $keepAll = true ){ $form = array(); foreach( $_POST as $field => $value ){ $value = trim($value); if( array_key_exists($field,$fieldMaps) ) $form[ $fieldMaps[$field] ] = $value; elseif ( $keepAll ) $form[ $field ] = $value; } return $form; }
<form data-licenseKey="" data-noAjax="0" data-nocsrf="1" data-thankyou="0" action='login.php' name="jqueryform-a3d094" id="jqueryform-a3d094" method='post' enctype='multipart/form-data' novalidate autocomplete="on">
{ "validated": true, "fieldValues": { "email": "demo@demo.com", "password": "demo123" } }
<script type="text/javascript"> function ajaxSubmitCallback(res) { var data; try { data = $.parseJSON(res); } catch (e) {}; //console.log(res); if (data && data['validated'] === true) { location.href = 'my-account.php'; } } </script>
My Account page my-account.php
<?php /** * JQuery form backend customization demo script */ session_start(); if( true === $_SESSION['user.authenciated'] ) echo "You have logged in. Welcome!"; else echo "Access denied!";
Or download the source code of the customized backend project