Simple password protection for a Joomla page or section.

ozzie 14 Oct, 2010
Just a really simple application of Chrono Forms for those persons like me who have a beginner level of programming skills.
I needed a low security gateway to a page. Mainly to avoid accidental visits by the public to avoid confusion. However I needed to keep the nav menu visable/public for a sales team.

[attachment=0]seclock.jpg[/attachment]

Making this is very easy using the wizard.
[list]
  • Use a password field and submit button,

  • Call the form field "password"

  • In the validations tab enter the following code, [Provided by Bob in another thread], to create a stand alone password and error message in the server side valdation text area.

  • In this case password = "gatepw"

  • Ensure you enable server side validation by ticking the check box above the text area.

  • Set up your redirection URL to a page of choice.
  • [/list]
    'Tis Simple! [ when you know how ]

    <?php
    $password = JRequest::getString('password', '', 'post');
    if ( !$password || $password != 'gatepw' ) {
      return 'Please enter a valid password';
    }
    ?>

    The end result is a page with a password gateway to what ever page you wish to re-direct to upon successfull submission with out using a database for validation [similar to htaccess]
    kus_kus 17 Sep, 2013
    If you came here through Google Search pay attention to new code in CF v.4
    (taken from this thread)
    <?php
    $password =& $form->data['password'];
    if ( !isset($password) || !$password || $password != '12345' ) {
      $form->validation_errors['password'] = 'Please enter a valid password';
      return false;
    }
    ?>
    This topic is locked and no more replies can be posted.