form generators

I'm looking for an easy way to create a customized form on a page in my Zenphoto site http://share.gospelriver.com. The form would be similar to the one at http://www.blackrivergospel.org/bookmarks.html

Does anyone have a suggestion on an inexpensive way to do this that would likely not lead to lots of spam submissions as a bonus? I have a little php coding experience but not a lot.

I know Zenphoto has a few form options but I haven't found that they allow easy customization of the fields without a bunch of coding. If you can tell me different please do. I know there are lots of form generators out there but there are so many I'd be glad to hear which work well for others. I know how to make basic html forms but I would need to do research on how to create the cgi scripts etc and I'd rather not have to worry about figuring out all the security, captcha, etc. that goes along with it.

Thanks in advance.

Comments

  • acrylian Administrator, Developer
    From a quick look (I did not fully get the purpose of that), the example you posted above would require an extension/plugin. Just a form alone (which is basic html) will never provide the functionality of that example or whatever you exactly wish to do.

    There is no "inexpensive" way other than coding it yourself.
  • Well, I elected to use phpFormGenerator for now. It seems to work ok, but I'm wondering if I will need some kind of spam filter for those custom forms. There is a lot of discussion on this type of thing on the forum but some has to do with the built-in comments functionality and it appears reCaptcha may not be an option-- I can't add php to the html input fields.
    Any input on this would be appreciated-- is there a fairly simple way to implement a) Zenphoto's captcha with custom forms or b) some other spam filtering device?

    Thanks.
  • acrylian Administrator, Developer
    Well, you did not tell what happens with the form data after someone clicked submit. Depending on that you will need further coding... That's all I said.

    For our captcha or spamfilters please see the documentation and/or look at the plugins itself. Also look how it is done on the comment_form plugin for example. It should be possible to adapt that but of course since the spam filters are tied to our form usage you might need to adapt code (don't know as I don't remember offhand).
  • It looks like reCaptcha would be pretty easy to implement if I could just add the following php to my form (phpFormGenerator submits to a php file as below).

    `

    <?php
    require_once('recaptchalib.php');
    $publickey = "your_public_key"; // you got this from the signup page
    echo recaptcha_get_html($publickey);
    ?>


    `
    Is there any way to do this without coding a special template for each page that has a form on it?
  • Zenphoto v1.4.2 (currently in Beta) has a reCaptcha plugin. The general use of captcha is examplified by the comment_form plugin, among others.

    Of course, to use this it has to be encoded on the form and the form post processing. No way around that. (Just as you will have to process the rest of the fields from your custom form.)

    Unless phpFormGenerator has some mechanism for adding fields, you will have to insert the code after the fact.
  • Thanks sbillard-- so my question really is, how do I encode it in the form? I can't enter php in the WYSIWYG html editor for the page. I don't know how to insert snippets of php into my form code without coding the whole page as a template.

    Thanks.
  • acrylian Administrator, Developer
    You should either program a theme custom function or a plugin. If it is a special page you want to use creating a custom theme page is the way to do. See the tutorials please.
  • OK, thanks acrylian. What I am looking for is something like Wordpress does where you can add something like [captcha] in brackets in the html editor and then Zenphoto inserts code in that spot. I don't see anything like that in the tutorials, so I'm assuming it would have to be coded as a new plugin.

    So it appears the easiest way to do what I want to do is to code a custom theme page for each form and use the multiple layouts plugin to choose that layout for the page so I don't have to duplicate the whole theme for each custom page...

    wait-- would the codeblock work for me? Could I possibly add just the last few lines of the form including the submission buttons in there and just have a call to the codeblock in my page template at the right location, as long as I don't have any text after my form? It doesn't look like the html editor adds any extra tags so maybe this would work... If you could just comment on what you think would be best I'll work on going in that direction.

    To recap, I'm wondering if it would be possible to create/edit the majority of my form in the html editor and just finish it with captcha and Submit/Reset buttons using a page codeblock.

    Wait again... another idea that just popped in that's better maybe is perhaps I could use a <span id="captchaForm"> inside the html form at the location where I need the captcha and use getElementById to add the code. This way I wouldn't have to worry about whether more text is entered after the unclosed table on the page as with the previous method.

    So I would just add something like this code to pages.php (not debugged):
    `
    require_once('recaptchalib.php');
    $publickey = "your_public_key"; // you got this from the signup page
    if(document.getElementById("captchaForm")!=null){
    document.getElementById("captchaForm").innerHTML = <?php echo recaptcha_get_html($publickey); ?>;}
    `
    which might add the recaptcha into any custom form I create with the WYSIWYG editor. Think that would work?

    Thanks for any input you can give on this...

    By the way, an example page with a form is here:
    http://share.gospelriver.com/index.php?p=pages&title=request-a-bookmark
  • acrylian Administrator, Developer
    Yes, indeed Zenphoto does not have the [code] way of adding stuff. If you don't want to code custom pages the codeblocks are an alternative (the theme must support them though). You can add there either php/html etc. If you need several forms on different pages the easiest again is either to code a theme function or plugin and just put the function to print with possibly parameters set in there.

    Your code example will not work as
    1. You mix JS and PHP wrong
    2. JS and PHP work completly differently.
    The php code you insert will not be exectuted because PHP has already been exectute when you do this (JS runs in the browser after getting files from the server while PHP is executed before the browser gets files).
  • Well, the idea of finishing the table with the codeblock doesn't work because the html editor automatically fills in the missing tags.

    You're right, my coding was way off. I tried
    `
    <?php
    require_once('http://mysitecreations.com/recaptcha/recaptchalib.php');
    $publickey = "public_key"; // you got this from the signup page
    echo "<script type='text/javascript'>document.getElementById('insertCaptcha').innerHTML = ".recaptcha_get_html($publickey)."";
    ?>
    `
    but it doesn't find the recaptcha_get_html function and I'm guessing the html inserted wouldn't be compatible anyway...

    So it looks like I'm back to square one on this. :(
    Probably will shelve it until I start getting a lot of spam and have to do something about it I guess...
  • I tried one more thing-- putting the whole form in the codeblock, but I still get an error "call to undefined function" so either I'm not including the php file correctly or something...

    Of course doing it this way would mean I would have to have a separate page for each language, but at least I would be able to do everything from within admin rather than lots of extra coding.
  • If my page is located at
    http://share.gospelriver.com/index.php?p=pages&title=request-a-bookmark

    Would it work to place the
    recaptchalib.php
    file in the root directory and require it with
    `require_once('recaptchalib.php');`

    I don't get an error that it's not finding the required file but if it's not seeing the function inside there must be something wrong...
  • ... or to get both languages I suppose I could still call the respective form code with [code] in the html for each language? Where is the documentation for doing this?
  • acrylian Administrator, Developer
    May I suggest that you sort a little what you actually want to do?
    Also:
    Would it work to place the
    recaptchalib.php
    file in the root directory and require it with
    require_once('recaptchalib.php');

    I don't get an error that it's not finding the required file
    From within the theme you have to use the WEBPATH constant, a theme is technically not in the root. So again best is to create a theme custom function (-> theming tutorial) or create a plugin (-> plugin tutorial).
    I suppose I could still call the respective form code with [code] in the html for each language?
    You cannot call aynthing using [code] on Zenphoto as already said.

    Regarding languages please see the multilingual and translation tutorials. In any case you will have to do some work.
    For a static form like yours you have to two ways to make the forum multilingual:
    1) You have to add gettext to all static strings and then use either the theme or plugin (depending on what you create) translation method for it as explained on the translation tutorial.
    2) Or use the site in multilingual mode and paste the form already statically translated in the html. Note that PHP will NOT work in text fields.

    Please understand that this is in danger to exceed the free forum support at least by us developers.
  • Thanks so much for all your help and tips.

    I'm sorry, I misread your [code] statement... saw "yes indeed" and not the "not" for some reason.

    I won't expect further replies from developers.

    Nathan
  • acrylian Administrator, Developer
    Of course you are welcome with further questions. But first you just should sort a little what you want to do and read a little on the docs to get more familiar with Zenphoto.
  • Yes, I need to become more familiar with zenphoto documentation.

    What I want to do I thought at conception was quite simple: reduce spam from custom forms that I add, such as the form at http://share.gospelriver.com/index.php?p=pages&title=request-a-bookmark

    Using recaptcha requires adding three lines of php code in the form, so sounded easy. However, within the zenphoto framework this appears to be much more difficult than anticipated. I could, as you say, create a custom function that creates the form. I couldn't use this with the html editor, but then I'm coding much of the form by hand anyway. I just find it nicer to do finishing touches in WYSIWYG and have everything right there visible.

    I may just have to wait until after the next zenphoto release with recaptcha as I'm not sure I have the time to look into all the ins and outs of creating plugins and functions. Not sure if that release will address my current issue though...
  • acrylian Administrator, Developer
    Well, if you want to use your form as a tool within Zenphoto context and use benefits of the framework you will have to get familiar with a few more things (that is the case for any CMS).

    The easiest solution otherwise is probaly to create static custom pages with the form generated. I don't know the form tool but you might need to think about security and sanitizing as well.
  • :-)
    I actually figured it out.

    Using my full server path solved the includes and function not found issue.

    Adding the php into the form and including the full form in codeblock 2 solved the form issue.

    For the present this means I have different pages for each translation, but that's very do-able.

    Thanks again for your help with this!
Sign In or Register to comment.