PHP: ApplicationForm only accessible with a validation code

Hello Gibbon-Team and Gibbon-Community,

a new day - a new question. :stuck_out_tongue:
We want our applicationForm only accessible with a validation code.

applicationForm.php - Userinterface

applicationForm.php - Code


  1. Is it possible to use RegEx in the addValidation line( [\β€˜β€™.__(β€˜123456789’).β€˜\’], ).
    (I need sth. like this ([a-zA-Z][0-9]){4}).

  2. I want to use toggleVisibilityByClass if the validation code was correct. Can i somehow use addConfirmsubmit to archieve this?
    (only found onSelect and on Checkbox)

PHP is getting better an better.
Thank you in advance!

Hi ub123,

Looks like you’ve done a great job setting up some validation to confirm that they’ve entered the code. Validation is not necessarily tied to the toggleVisibilityByClass, this method is more for toggling sub-sections of the form on and off.

One way to approach what you’re trying to achieve is to break it up into two forms. You could use the code you have there to display the first form using a conditional to check the $_POST[β€˜confirm’] value. The users would fill that form in and submit it, which would post the confirm value they entered back to the same applicationForm.php script. Then, if the confirm value is correct, it will skip displaying the first form and continue displaying the regular application form.

The pseudocode might looks a bit like this:

`$confirm = $_POST['confirm'] ?? '';

if ($confirm != '123456789') {
    // Display your first form, with the confirmation code and a submit button.
    // This is a server-side check, because client-side checks can be circumvented.

    $form = Form::create('applicationForm', $_SESSION[$guid]['absoluteURL'].'/index.php?q=/modules/Students/applicationForm.php');

    // ... add your form code with the confirmation and a regular submit button.

    echo $form->getOutput();

    // Followed by a return statement to stop displaying the rest of the form.

Once again Thank you Sandra!
This works even better than intended. :slight_smile: