Captcha

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Captcha

Beitragvon Michael_S » Fr 11. Jul 2014, 16:42

I'm trying to get the <we:captcha> function to work but I can't find a clean example. Is this working for formmail forms and if yes can someone post an example of how to use the tags (<we:captcha> and <we:ifCaptcha>).

Thanks,

Michael.
Production Area
London, UK
http://productionarea.com

mokraemer
Senior Member
Beiträge: 3619
Registriert: So 8. Aug 2010, 01:23
Wohnort: Mainz

Re: Captcha

Beitragvon mokraemer » Fr 11. Jul 2014, 22:14

First, if you haven't yet, you should do an update to 6.3.8-s2 which changes the behaviour of captcha.
Using captcha is simple. Try this:

Code: Alles auswählen

<we:ifCaptcha name="solution">
checked ok
</we:ifCaptcha>
<we:captcha width="600" height="25" maxlength="8" fontsize="8,25" fontcolor="#000000,#AAAA00,#BB00BB" case="lower"  style="strikeout" angle="15" />
<form>
<input type="text" name="solution" />
<input type="submit"/>
</form>
You'll get an image and an input field. If your code matches, you'll see "check ok". With the parameters mentioned, you can change the lenght, color, fontsize, ... to meet your desired complexity of the captcha.
Note: that the page generates a new captcha, so putting ifCaptcha below we:captcha will break your test. (I think it this obvious).

In combination with "formmail" you have to do sth. like:

Code: Alles auswählen

<we:ifCaptcha name="solution">
<we:formmail/>
<we:else/>
You're captcha didn't match, try again....
</we:ifCaptcha>
webEdition-Kern-Entwickler

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Captcha

Beitragvon Michael_S » Mo 14. Jul 2014, 18:50

Hi,

I've updated to 6.3.8-s2 (6.3.8.0, SVN-Revision: 6985) but I still can't get the Captcha to work. I can see that the form submission is checking something as there is a pause before the success or error page. But if I complete the required fields and enter the incorrect Captcha the form is still submitted successfully?

Here's the code I'm testing:

Code: Alles auswählen

<we:ifCaptcha name="areYouHuman">
<we:formmail />
<we:else/>
You're captcha didn't match, try again ...
</we:ifCaptcha>

<we:form 
type="formmail" 
name="contact" 
nameid="contact" 
method="post" 
target="_self" 
recipient="hello@##########.com" 
onsuccess="72" 
onerror="73" 
onmailerror="74" 
from="no-reply@##########.com" 
subject="Website enquiry" 
order="Name,Phone,Email,Message" 
required="Email,Message" 
mimetype="text/html">

<p>Name:</p>
<p><input name="Name" type="text" /></p>

<p>Phone:</p>
<p><input name="Phone" type="text" /></p>

<p>Email*:</p>
<p><input name="Email" type="text" /></p>

<p>Message*:</p>
<p><textarea name="Message" rows="2" cols="50"></textarea></p>

<p>Captcha*:</p>
<p><we:captcha width="300" height="50" maxlength="4" subset="num" fontcolor="#000000" fontsize="24" /></p>
<p><input name="areYouHuman" type="text" /></p>

<p><input type="submit" value="Submit" /></p>

</we:form>
Michael.
Production Area
London, UK
http://productionarea.com

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Captcha

Beitragvon Michael_S » Mo 14. Jul 2014, 21:18

I moved the Captcha tag out of the form and below the ifCaptcha but still get the same result with the form submitting regardless of the code being correct or not?
Production Area
London, UK
http://productionarea.com

mokraemer
Senior Member
Beiträge: 3619
Registriert: So 8. Aug 2010, 01:23
Wohnort: Mainz

Re: Captcha

Beitragvon mokraemer » Mo 14. Jul 2014, 22:50

you're right. sorry I didn't see that.

you have to change your form-tag to

Code: Alles auswählen

<we:form type="formmail" id="self"[...]>
the attribute id="self" or any other id will tell that tag not to be redirected to the formmail script and instead to your template. There you have the control to include the formail script yourself via <we:formmail/>
webEdition-Kern-Entwickler

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Captcha

Beitragvon Michael_S » Mo 14. Jul 2014, 23:54

Hi Mokraemer,

If I add the id="self" attribute to <we:form> nothing happens and its not listed as a valid attribute in the english language form/formmail tag.

Code: Alles auswählen

<we:form type="formmail" id="self"[...]>
... if I change 'onsuccess' to 'self':

Code: Alles auswählen

<we:form type="formmail" onsuccess="self"[...]>
On submit the /webEdition/we_formmail.php page loads regardless of if the captcha code is correct or not and I receive the email. So it seems that onsuccess="self" triggers the we_formmail.php script but id="self" does not?

Here's the form/formmail code I'm testing using the id="self" attribute, this is not working for me :-(

Code: Alles auswählen

<we:ifCaptcha name="code">
<we:formmail />
</we:ifCaptcha>

<we:ifNotCaptcha name="code">
Sorry, your captcha code didn't match, try again ...
</we:ifNotCaptcha>

<we:captcha width="300" height="50" maxlength="4" subset="num" fontcolor="#000000" />
<input name="code" type="text" />

<we:form  
type="formmail" 
id="self" 
name="contact" 
nameid="contact" 
method="post" 
target="_self" 
recipient="hello@##########.com" 
from="no-reply@##########.com" 
subject="Website enquiry">

<p>Email*:</p>
<p><input type="text" name="Email" /></p>
<p><input type="submit" value="Submit" /></p>

</we:form>
Production Area
London, UK
http://productionarea.com

mokraemer
Senior Member
Beiträge: 3619
Registriert: So 8. Aug 2010, 01:23
Wohnort: Mainz

Re: Captcha

Beitragvon mokraemer » Di 15. Jul 2014, 00:30

try this:

Code: Alles auswählen

<we:ifCaptcha name="code">
<we:comment>for test purpose, i suggest to only have a message shown instead of getting hundreds of mails during test :-)</we:comment>
<we:formmail />
</we:ifCaptcha>

<we:ifNotCaptcha name="code">
<we:ifVarSet type="post" name="code"><we:comment>only show this error, if the form was filled but had an invalid code</we:comment>
Sorry, your captcha code didn't match, try again ...
<we:else/>
<we:form  
type="formmail" 
id="self" 
name="contact" 
nameid="contact" 
method="post" 
target="_self" 
recipient="hello@##########.com" 
from="no-reply@##########.com" 
remove="code"
subject="Website enquiry">

<p>Email*:</p>
<p><input type="text" name="Email" /></p>
<p>Plse confirm the following cpatcha...
<we:captcha width="300" height="50" maxlength="4" subset="num" fontcolor="#000000" />
<input name="code" type="text" />
</p>
<p><input type="submit" value="Submit" /></p>


</we:form>
</we:ifVarSet>
</we:ifNotCaptcha>
webEdition-Kern-Entwickler

mokraemer
Senior Member
Beiträge: 3619
Registriert: So 8. Aug 2010, 01:23
Wohnort: Mainz

Re: Captcha

Beitragvon mokraemer » Di 15. Jul 2014, 00:55

I think the english documentation is old. Due to the license change in webedition the english documentation was not really updated since that time.
We're currently discussing how to handle this problem, but in the meantime, I suggest to you to use
a) the tag-wizzard for the attributes, which is managed by the developers and is most up-to-date (but doesn't have an documentation - right)
b) use the english documentation to get a rough understanding of the tag
c) use http://webedition.org/de/webedition-cms ... -referenz/ with a translator (I think they work pretty well these days - at least to understand).

To make things short (most important changes in tags which you might not know):
Almost any tag with an id attribute understands "self" as destination.
Any tag can have a comment attribute, which is filtered and is only used for the developers readability.
Any tag which produces output (not blocks,...) can redirect their output via "to" and "nameto" to a variable.
webEdition-Kern-Entwickler

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Captcha

Beitragvon Michael_S » Di 15. Jul 2014, 01:12

Hi mokraemer,

Good advise, I always use the tag wizard as this is the best way to avoid mistakes and I also try to avoid using custom php code. and translating the forum has been interesting over the years but as you say its getting better and generally I can understand the threads and code.

The Captcha function has been in webEdition for a long time but every time I try to get it to work it fails :-( Should I try it with a beta installation, I have MAMP running so its easy to test.

Thanks for your help so far.

Michael.
Production Area
London, UK
http://productionarea.com

ThomasGoebe

Re: Captcha

Beitragvon ThomasGoebe » Di 15. Jul 2014, 09:56

Hi Michael,

we:form type="formmail" always uses the webEdition form handler. Except when yout tell webEdition in the settings not to do.
So: open settings, tab "formmail" and set the option to send formmail with a webEdition document. (i don't know the exact english translation of that setting).

Then yout code should work.

Attention: with this setting you must always use we:form type="formmail" with an id="" attribute and in the target document must be a <we:formmail /> before any output to the browser. <we:formmail /> makes a header redirect to the success or error page, so even a blank before <we:formmail /> will cause an error.

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Captcha

Beitragvon Michael_S » Di 15. Jul 2014, 10:13

Hi Thomas,

I can see that I'm making some mistakes by not passing the form request onto a target document so will give that a try.

Is it worth me switching the backend on a MAMP installation to German to look at the we:form/formmail tag widget, I get the feeling that I'm missing something in the English view. Would you expect to see the 'id' attribute when selecting we:form/formmail or is this inserted manually?

Thanks,

Michael.
Production Area
London, UK
http://productionarea.com

e_herrmann
Senior Member
Beiträge: 1319
Registriert: Do 22. Mai 2003, 23:25

Re: Captcha

Beitragvon e_herrmann » Di 15. Jul 2014, 10:29

Hi Michael,
if you want to send a form via the we:formmail-tag you have to change the preferences. Go to preferences>common>formmail and switch "Call formmail via webEdition-Dokument." to yes. Then webedition is able to send the form via the the tag we:formmail and using the we:captcha.
Elko Herrmann
komplexx | internet.fotografie
web: http://www.komplexx.de

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Captcha

Beitragvon Michael_S » Di 15. Jul 2014, 13:54

Hi Elko,

Thanks for the information about the Preferences, that makes sense but easy to miss. It was confusing when the 'id' attribute was being mentioned in the we:form/formmail widget as this only shows when the "Call formmail via webEdition-Dokument." is set to yes.

I will give it a try.

Michael.
Production Area
London, UK
http://productionarea.com

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Captcha

Beitragvon Michael_S » Di 15. Jul 2014, 14:35

Not sure why this should be so problematic to implement ... but I still can't get it to work. The one thing which is not clear is what should be included on the forms action page but I'm not really getting that far as the formmail script is not doing anything?

I have the Formmail Preferences set to (a tip Elko I missed):

Code: Alles auswählen

Formmail confirmation function = On
Call formmail via webEdition-Dokument = Yes
... and I'm testing the following form code:

Code: Alles auswählen

<we:ifCaptcha name="code" formname="contact">
<we:formmail />
</we:ifCaptcha>

<we:ifNotCaptcha name="code" formname="contact">
Your captcha code did not match ... please try again.
</we:ifNotCaptcha>

<we:form 
type="formmail" 
id="75" 
name="contact" 
nameid="contact" 
method="post" 
target="_self" 
recipient="hello@##########.com" 
onsuccess="72" 
onerror="73" 
onmailerror="74" 
from="no-reply@##########.com" 
subject="Website enquiry" 
order="Name,Phone,Email,Message" 
required="Email,Message" 
remove="Code" 
mimetype="text/plain">

<p>Name:</p>
<p class="textinput"><input name="Name" type="text" /></p>
<p>Phone:</p>
<p class="textinput"><input name="Phone" type="text" /></p>
<p>Email*:</p>
<p class="textinput"><input name="Email" type="text" /></p>
<p>Message*:</p>
<p class="textarea"><textarea name="Message" rows="2" cols="50"></textarea></p>

<p>Captcha code:</p>
<p class="captcha"><we:captcha width="300" height="50" maxlength="4" subset="num" fontcolor="#000000" fontsize="24" type="png" /></p>
<p>Please enter the captcha code in the field below:</p>
<p class="textinput"><input name="code" type="text" /></p>

<p><input type="submit" value="Submit" /></p>

</we:form>
Production Area
London, UK
http://productionarea.com

Michael_S
Senior Member
Beiträge: 160
Registriert: Mi 4. Feb 2004, 02:39
Wohnort: London / UK
Kontaktdaten:

Re: Captcha

Beitragvon Michael_S » Di 15. Jul 2014, 18:53

Hi,

What ever I try I can't get the formmail function to work? Looking at the code the form should be rendering some hidden fields "captcha_error_page" and "captchaname" but on submission nothing is posted.

Code: Alles auswählen

<we:form type="formmail" id="self" [...]>

<input type="hidden" name="captcha_error_page" value="" />
<input type="hidden" name="captchaname" value="" />

</we:form>
Any help would be appreciated.

Michael.

P.S. Running version 6.3.8-s2 (6.3.8.0, SVN-Revision: 6985)
Production Area
London, UK
http://productionarea.com


Zurück zu „webEdition Basic Version“

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 9 Gäste