We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15001
    • 697 Posts
    Hi Bob,

    I’m using again your SPForm snippet and encounter a problem during tests.

    The SPFormProc works correctly, but not after an error was done (no topic, bad email or wrong captcha, a.s.o.), despite the error messages are displayed as expected.

    In that case, if the visitor clicks the "Back" button in his browser, correct the mistakes and submits the form again, a blank page is displayed to him.
    What happens is that the browser does not redirect to the "Thank you" page and stays on the form processing document.


    The "Thank you" page comes only if the visitor makes all right from the beginning.
    Do other people encounter this problem ?

    I checked that the pages containing the [!SPForm!] and [!SPFormProc!] snippet calls are not cached and that both snippets are called in un-cached mode. All is OK.

    Is this a bug ?

    Thanks for your answer.
      • 3749
      • 24,544 Posts
      Quote from: Jul at Jan 04, 2010, 03:54 AM

      Hi Bob,

      I’m using again your SPForm snippet and encounter a problem during tests.

      The SPFormProc works correctly, but not after an error was done (no topic, bad email or wrong captcha, a.s.o.), despite the error messages are displayed as expected.

      In that case, if the visitor clicks the "Back" button in his browser, correct the mistakes and submits the form again, a blank page is displayed to him.
      What happens is that the browser does not redirect to the "Thank you" page and stays on the form processing document.


      The "Thank you" page comes only if the visitor makes all right from the beginning.
      Do other people encounter this problem ?

      I checked that the pages containing the [!SPForm!] and [!SPFormProc!] snippet calls are not cached and that both snippets are called in un-cached mode. All is OK.

      Is this a bug ?

      Thanks for your answer.

      I’m sorry, I can’t duplicate that. (You can try it at the site in my sig.)

      I don’t know what would cause that to happen.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 15001
        • 697 Posts
        Bob, thanks for your answer. I deleted the two last messages as I could find what was wrong.

        The problem was due to $requireKeyboard being set to true in the configuration file.
        One have to set it to false:
        $requireKeyboard = false;


        In my tests, I was entering a wrong equation result, going to previous page and entering the correct equation result. Then, clicked the "Submit" button again. Despite the new keystroke(s) in the equation field, the check relative to keystrokes failed.

        Was the problem with $requireKeyboard=true the expected behaviour or some special case that SPForm does not handle ?
          • 3749
          • 24,544 Posts
          $requireKeyboard and $requireMouse are somewhat unreliable when used alone. Did you try $useMouseOrKeyboard (the recommended setting)? Also, do you have javascript turned on?
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 15001
            • 697 Posts
            I didn’t try $useMouseOrKeyboard but Javascript was turned on.
              • 29525
              • 388 Posts
              I’ve using SPForm on a new site with a single email address. Works fine.

              I want the each note to go to two addresses. I understand the two addresses should be comma separated, but if add a second email address and send a note, I get an error message "invalid recipient".

              I’ve tried this with several different email address so I don’t really think its a problem with the email addresses themselves.
              Next Stage Business: Next Stage Business: [email protected],[email protected]
              


              Any ideas?
                www.terrybarthdesign.com
                • 3749
                • 24,544 Posts
                You don’t say which version you have, but in the Evolution version of SPForm, this line in spformproc.inc.php is the culprit:

                if (! preg_match("/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i", $recipient, $result)) {echo $spf_lang['bad-recipient']; error_log("Bad email address"); exit;}


                You could comment it out (though that would have security implications) or edit it.

                As an alternative, you could use $mailAlso for the second address if that would work.

                I’ll try to look into it when I get time.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 29525
                  • 388 Posts
                  Thanks BobRay

                  I assume that when you say use $mailAlso for the second address that I would manually add the second address to this variable in the spformprocinc.php?

                  By the way, I see in the code you referenced the error message is "bad recipient" however, the message I received was "invalid recipient".

                  Stay tuned.
                    www.terrybarthdesign.com
                    • 3749
                    • 24,544 Posts
                    Terry,

                    You’d add

                    $mailAlso="[email protected]"


                    in the spfconfig.cfg.php file (line 211 in the version I have).

                    Also, bad-recipient is the language key, the message you see is the message that corresponds to that key in the English language file.

                    BTW, here’s some code for that section of spformproc.inc.php (or the spformproc snippet if the code is there). I haven’t tested it, but it should solve your problem.

                    // check for email injections, logical email address and overlong fields
                    
                    $spf_regex = "/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i";
                    
                    $rs = explode(',',$recipient); // handle multiple addresses separated by commas
                    
                    foreach ($rs as $r) {
                        if (! preg_match($spf_regex, $r, $result)) {echo $spf_lang['bad-recipient']; error_log("Bad email address"); exit;}
                        if (strlen($r) > 65) {echo $spf_lang['bad-recipient-length']; error_log("recipient length > 65"); exit;}
                    }
                    
                    


                    The code above replaces everything above the line that starts with:

                    if (strlen($finalSubject) > 100) 


                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 29525
                      • 388 Posts
                      I think using $mailAlso="[email protected]" would be the easiest. However, I when tried this, I see the cc info in the header of the note, but I don’t receive the cc note itself.

                      I’m going to try this on another server that isn’t a live site. Perhaps, I’ll determine what is different here?

                      I’ll let you know.
                        www.terrybarthdesign.com