Jump to content
n0sleeves

Anyone have a good form processing script?

Recommended Posts

I like the one at tectite.com but curious as to what everyone else is using. Finding any on google seems to bring up some pretty old  and unsafe techniques.  I don't like paid services like Jot Form, etc.  Ryan's form script is awesome and is what I usually use. However, sometimes I don't get to use PW on projects :( 

Share this post


Link to post
Share on other sites

My solution for simple forms : Validation Module

I used GUMP validation library with my custom usage additions. You can check my usage additions : https://github.com/trk/Validation/blob/master/README.md#example-long-format

Also i wrote recaptcha module for form security, but didn't publish it yet: https://github.com/trk/Recaptcha

Usage:

$recaptcha = wire('modules')->get('Recaptcha')->verifyResponse($_POST['g-recaptcha-response']);
if(!$recaptcha) {
     echo 'reCAPTCHA validation not ok!';
}

You can add recaptcha as a rule to validation module like:

'g-recaptcha-response' => array(
        'label'     => 'Security Question',
        'rule'      => 'required|boolean',
        'type'      => 'captcha'
    )
  • Like 1

Share this post


Link to post
Share on other sites

Recaptcha module looks nice. You should add it to the modules directory :)

Just a quick tip: please use wire('input')->post->g-recaptcha-response instead of $_POST (if possible).

  • Like 2

Share this post


Link to post
Share on other sites

I thought I'd post this example of a working solution of ukyo's module with FrontendUser.

Thanks to ukyo & pwFoo for troubleshooting and everything.

<?php
if(!$user->isLoggedin()) {
  // load module
  $fu = $modules->get('FrontendUser');
  $recaptcha = $modules->get('Recaptcha');
  // prepare register form
  $fu->register();
 
  $form = $fu->form;

  // process register / form submit
  $redirectDestination = $pages->get(1)->url;
 
        $form->addHookAfter('processInput', function() use($fu, $recaptcha, $input) {
        if(isset($input->post) && $input->post('fuRegisterForm') == 'fuRegisterForm') {
          $recaptchaverify = $recaptcha->verifyResponse($input->post('g-recaptcha-response'));
          if(!$recaptchaverify) {
               $fu->form->fhSubmitBtn->error('reCAPTCHA validation not ok!');
          }
        }
        });
  $fu->process($redirectDestination);

?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title><?php echo $title; ?></title>
        <link rel="stylesheet" type="text/css" href="<?php echo $templatesurl; ?>css/mystyle.css" />
    <link rel="stylesheet" type="text/css" href="<?php echo $templatesurl; ?>css/somestyle.css" />    
    </head>
    <body>
    <div class="container">
    <p>Ylläpito vahvistaa kaikki rekisteröitymiset. Saat sähköpostia, kun olet saanut käyttöoikeudet.</p>
<?php  // output register form
  echo $fu->render();
  echo $recaptcha->render();
?>
    </div>
    </body>
</html>
<?php  die();
}

Share this post


Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...