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.htmlDoes 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
There is no "inexpensive" way other than coding it yourself.
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.
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).
`
<?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?
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.
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
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).
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...
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.
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...
Also: 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). 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.
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
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...
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!