Zen Cart Logo
Forums / All Other Contributions/Addons / Simple CSS/PHP AntiSpam solution for a contact form

Simple CSS/PHP AntiSpam solution for a contact form

Views: 49,007

Results 21 to 40 of 131
2 Sep 2011, 9:02 AM
#21
billyboyle avatar

billyboyle

Zen Follower

Join Date:
Jul 2011
Location:
Glasgow, Scotland
Posts:
115
Plugin Contributions:
1

Simple CSS/PHP AntiSpam solution for a contact form

Oh one other thing.
Doesn't strike me as the type of mode that is base version dependant, but thought I should check.

I'm using v1.3.9h

is this still good for this mode, hopefully?

Today I am trying something different. Read the install.txt Read the FAQ Read the forum for answers; Then Install the mod. ;-)
AML Candles

2 Sep 2011, 9:19 AM
#22
billyboyle avatar

billyboyle

Zen Follower

Join Date:
Jul 2011
Location:
Glasgow, Scotland
Posts:
115
Plugin Contributions:
1

Re: Simple CSS/PHP AntiSpam solution for a contact form

dw08gm:

  1. Found the following hides well in templates/tpl_whatever.
<div style="visibility:hidden; display:none;"> <label class="inputLabel" for="confirm_email">Confirm Email: </label> <input id="confirm_email" name="leaveblank" type="text"><span class="alert"><strong> * </strong></span> <br class="clearBoth" /> </div> ``` > > 2. Also replaced the following in modules/pages/whatever/header_php.php > > ``` if (!empty($leaveblank)) { exit; } ``` > > with > > ``` if (!empty($leaveblank)) { zen_redirect(zen_href_link(FILENAME_WHATEVER, 'action=success')); } ``` > > as it gives the impression of the form passing. > > Cheers and thanks for the heads up.

Hi as a noob I do need to check if Im getting it right. So I hope you don't mind me checking.

If I was applying this to my contacts us page would the correct edit be? :unsure:

if (!empty($leaveblank)) {
zen_redirect(zen_href_link(FILENAME_CONTACT_US, 'action=success'));
}
or would it be;
if (!empty($leaveblank)) {
zen_redirect(zen_href_link(CONTACT_US, 'action=success'));
}

Today I am trying something different. Read the install.txt Read the FAQ Read the forum for answers; Then Install the mod. ;-)
AML Candles

2 Sep 2011, 10:05 AM
#23
billyboyle avatar

billyboyle

Zen Follower

Join Date:
Jul 2011
Location:
Glasgow, Scotland
Posts:
115
Plugin Contributions:
1

Re: Simple CSS/PHP AntiSpam solution for a contact form

adem.i:

I found the solution to the problem I had previously discussed.

for some reason, I didn't have a subject box and in the code in this thread , the line '!empty($name) and !empty($subject) and empty($leaveblank)) {' can't be used because when a real person submits enter, zen cart will be waiting for an entry in a subject box that doesn't exist, so just modify the line by

!empty($name) and empty($leaveblank)) {

alone


Are you saying?
this:
if ($zc_validate_email and !empty($enquiry) and !empty($name) and !empty($subject) and empty($leaveblank)) {
should look like this:
if ($zc_validate_email and !empty($name)and empty($leaveblank)) {

Did you get this to work?
Not really being that knowledgeable in php I really need to check things out a lot and hope you don't mind me asking what other might see as a silly question.

I can't get the form to send mail after I edit the php and was hoping this was the answer.
It works when I put text in the hiden field (as if I were a bot)
does nothing when I leave the field blank. :ohmy:

Thanks Billy

Today I am trying something different. Read the install.txt Read the FAQ Read the forum for answers; Then Install the mod. ;-)
AML Candles

2 Sep 2011, 10:38 AM
#24
billyboyle avatar

billyboyle

Zen Follower

Join Date:
Jul 2011
Location:
Glasgow, Scotland
Posts:
115
Plugin Contributions:
1

Re: Simple CSS/PHP AntiSpam solution for a contact form

I know, yak yak yak.

Here's another question for the knowledgeable.
In the line

if ($zc_validate_email and !empty($enquiry) and !empty($name) and !empty($subject) and empty($leaveblank)) {

there is the use of "!" before some "empty" "perameters"

further down the same file where empty($leaveblank)
is called in the error checking part

if (!empty($leaveblank)) {
exit;
it has a "!".

I know this is not a php tutorial site, but I am trying to understand why this does not work with about 4 weeks of self-learning in php.

So does it matter if the "!" is used or not?
Does it matter if "!" is used inconsistantly (if that is what it is)?
does it not matter because it is being correctly used in the error check and should not be used in the earlier if statement?

Please help Billy

Today I am trying something different. Read the install.txt Read the FAQ Read the forum for answers; Then Install the mod. ;-)
AML Candles

2 Sep 2011, 11:41 AM
#25
billyboyle avatar

billyboyle

Zen Follower

Join Date:
Jul 2011
Location:
Glasgow, Scotland
Posts:
115
Plugin Contributions:
1

Re: Simple CSS/PHP AntiSpam solution for a contact form

OKay one more question (for just now anyway). :cool:

After re-editing:
/includes/modules/pages/contact_us/header_php.php
:yes:
with the suggestion from adem.i

I think it is now functioning as intended:
Normal situation; human contact form sends mail to store address.
:yes:
with the suggestion from dw08gm
Bot situation; input form fakes sending mail to store address.
:clap:
Can anyone else confirm that these are two mods to the mod are correct?
:wink:
Would this be a complete list of files to aply the pair of mods to in order to cover to whole store;

/includes/modules/pages/contact_us/header_php.php
/includes/templates/template_default/templates/tpl_contact_us_default.php

/includes/modules/create_account.php (would this even be needed?)
/includes/modules/pages/create_account/header_php.php
/includes/templates/template_default/templates/tpl_modules_create_account.php

/includes/templates/template_default/tpl_tell_a_friend.php
/includes/modules/pages/tell_a_friend/header_php.php

Thanks guys I know how anoying I can be when I start on learning something new.
This is like trying to learn to drive in a foreign country and your instructor does not speak the same language as you.
But I'm lovin' it. :frusty::clap:

Today I am trying something different. Read the install.txt Read the FAQ Read the forum for answers; Then Install the mod. ;-)
AML Candles

2 Sep 2011, 11:58 AM
#26
billyboyle avatar

billyboyle

Zen Follower

Join Date:
Jul 2011
Location:
Glasgow, Scotland
Posts:
115
Plugin Contributions:
1

Re: Simple CSS/PHP AntiSpam solution for a contact form

Okay I lied, one more; :blink:

If the list of files I asked about in the previous post is correct, does anyone know where abouts in these file I would add the mods.

I know I could spend hours adding things, breaking things, and getting generally frustrated :frusty:

Just thought it might be easier to ask and stay calm :mellow:

Today I am trying something different. Read the install.txt Read the FAQ Read the forum for answers; Then Install the mod. ;-)
AML Candles

2 Sep 2011, 12:15 PM
#27
billyboyle avatar

billyboyle

Zen Follower

Join Date:
Jul 2011
Location:
Glasgow, Scotland
Posts:
115
Plugin Contributions:
1

Re: Simple CSS/PHP AntiSpam solution for a contact form

Hope i'm not being too anoying
:wacko: :huh:

Today I am trying something different. Read the install.txt Read the FAQ Read the forum for answers; Then Install the mod. ;-)
AML Candles

4 Sep 2011, 12:55 PM
#28
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,017
Plugin Contributions:
2

Re: Simple CSS/PHP AntiSpam solution for a contact form

Multiple posts within 24 hours in the same thread will not win you many friends. Nevertheless:

a) The exclamation mark before code generally means "not", ie !empty = not empty.

b)```
If I was applying this to my contacts us page would the correct edit be?

if (!empty($leaveblank)) {
zen_redirect(zen_href_link(FILENAME_CONTACT_US, 'action=success'));
}
or would it be;
if (!empty($leaveblank)) {
zen_redirect(zen_href_link(CONTACT_US, 'action=success'));
}


Use whatever your existing code says in the "zen_redirect" line. 

c)> Would this be a complete list of files to aply the pair of mods to in order to cover to whole store;

IIRC, yes, the header_php and the corresponding tpl_.
But test and see.

d)Works in 139h.

Now go and have a good rest.
5 Sep 2011, 10:45 PM
#29
billyboyle avatar

billyboyle

Zen Follower

Join Date:
Jul 2011
Location:
Glasgow, Scotland
Posts:
115
Plugin Contributions:
1

Re: Simple CSS/PHP AntiSpam solution for a contact form

@dw08gm Thank you!

I appreciate your help.
I do realise that multiple posting is very bad form and do appologise for that. I'm only 46 and still just a kid. :blush:

I am still working through many mods to get the store ready and will be returning to this one, Security and Anti- anything being very important.

Today I am trying something different. Read the install.txt Read the FAQ Read the forum for answers; Then Install the mod. ;-)
AML Candles

6 Sep 2011, 12:03 AM
#30
magicman avatar

magicman

Zen Follower

Join Date:
Oct 2007
Location:
MA, USA
Posts:
385
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

I tried using this with the Create Account Page and after customer filled out form and hit submit, it just redirected to a blank page and no customer was created.

I have removed it to see if I could figure out what is wrong.

Thank you, Sincerely, MagicMan

7 Sep 2011, 9:44 AM
#31
billyboyle avatar

billyboyle

Zen Follower

Join Date:
Jul 2011
Location:
Glasgow, Scotland
Posts:
115
Plugin Contributions:
1

Re: Simple CSS/PHP AntiSpam solution for a contact form

MagicMan:

I tried using this with the Create Account Page and after customer filled out form and hit submit, it just redirected to a blank page and no customer was created.

I have removed it to see if I could figure out what is wrong.

Hi hope you don't mind a newbie trying to help, but I think I had the same issue till I read all the posts and pulled together a fix from everything.
Might even get my knuckles rapped for jumping in but here we go.

[legend] * * change to your file/folder name

modules/pages/pagename/header_php.php

after the line (around line 18):

$enquiry = zen_db_prepare_input(strip_tags($_POST['enquiry']));

add this:

$leaveblank = zen_db_prepare_input(strip_tags($_POST["leaveblank"]));

edit the line: (around line 23)

as follows:

if ($zc_validate_email and !empty($enquiry) and !empty($name) and !empty($subject) and empty($leaveblank)) {

Alternatively edit the line: (around line 23)

if ($zc_validate_email and !empty($name)and empty($leaveblank)) {

add this line: (around line 80)

//add this test that kills the page if the field was not empty.
if (empty($enquiry)) {
$messageStack->add('contact', ENTRY_EMAIL_CONTENT_CHECK_ERROR);
}

if (!empty($leaveblank)) {
  exit;
}

Alternatively add this:

//add this test that kills the page if the field was not empty.
if (!empty($leaveblank)) {
zen_redirect(zen_href_link(FILENAME_CONTACT_US, 'action=success'));
}

I may have it completely wrong, and if so (@those with knowledge please be gentle)

  1. the origional mod did send a bot to an empty page.
  2. I think it was doing the error action on the empty field and not if the field was not empty.

I have implement the above mods to my contact us page and it seem to be working. you can check it out at AML Camdles

Hope I've been of help Billy.

Today I am trying something different. Read the install.txt Read the FAQ Read the forum for answers; Then Install the mod. ;-)
AML Candles

7 Sep 2011, 8:15 PM
#32
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

@BillyBoyle, two issues with your post.

You quoted someone trying to use the code for Create Account page but showed code for Contact Us page.

Your Contact Us page does not have a blank input field. Did you remember to also edit:
includes/templates/YOUR_TEMPLATE/templates/tpl_contact_us_default.php

The learning is in the doing.

Potent Products

7 Sep 2011, 9:02 PM
#33
billyboyle avatar

billyboyle

Zen Follower

Join Date:
Jul 2011
Location:
Glasgow, Scotland
Posts:
115
Plugin Contributions:
1

Re: Simple CSS/PHP AntiSpam solution for a contact form

@Website Rob

Thanks for the input friend, allways welcome.

  1. As I said I only pulled together bits of info from other posts in the thread.

Pehaps you or even the [OP] could take this further and show us new guys where to put the code in the relevant files. I know it would sure help me out.

  1. Yes I have. It's just masked well, better that I thought even. Right under where it asks for your email address.

I don't mean it's just "blank" it's in camoflage. :smile:

Today I am trying something different. Read the install.txt Read the FAQ Read the forum for answers; Then Install the mod. ;-)
AML Candles

7 Sep 2011, 9:06 PM
#34
billyboyle avatar

billyboyle

Zen Follower

Join Date:
Jul 2011
Location:
Glasgow, Scotland
Posts:
115
Plugin Contributions:
1

Re: Simple CSS/PHP AntiSpam solution for a contact form

@dw08gm Thanks

Still no mail from Joe. :cool:

Today I am trying something different. Read the install.txt Read the FAQ Read the forum for answers; Then Install the mod. ;-)
AML Candles

7 Sep 2011, 9:28 PM
#35
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

I see it now and called: Confirm Email

That is somewhat confusing as there is a legitimate module for Confirming eMail address that is used by many people. You don't need to name the hidden input field. Just having the blank input field is enough.

Previous posts have stated where & how to make changes so not sure why you are asking to state it again?

The learning is in the doing.

Potent Products

7 Sep 2011, 10:30 PM
#36
billyboyle avatar

billyboyle

Zen Follower

Join Date:
Jul 2011
Location:
Glasgow, Scotland
Posts:
115
Plugin Contributions:
1

Re: Simple CSS/PHP AntiSpam solution for a contact form

Website Rob:

I see it now and called: Confirm Email

Just having the blank input field is enough.

Previous posts have stated where & how to make changes so not sure why you are asking to state it again?

Probably just a bit of over coding by a new guy. only been learning over the last 6 weeks.

was really half a sleep the first night night I was looking through this. I'll start from the front again and work my way through.

Thanks for the in put.

btw I like your tag.
Learning is in the doing!

Today I am trying something different. Read the install.txt Read the FAQ Read the forum for answers; Then Install the mod. ;-)
AML Candles

8 Sep 2011, 8:49 AM
#37
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,017
Plugin Contributions:
2

Re: Simple CSS/PHP AntiSpam solution for a contact form

Website Rob:

That is somewhat confusing as there is a legitimate module for Confirming eMail address that is used by many people. You don't need to name the hidden input field. Just having the blank input field is enough.

Confirm email was only given as an example.
You can name the field anything you like, eg favorite color or food.
You can even rename "leaveblank" to suit.

ps Looks like joe hit a wall.

8 Sep 2011, 3:37 PM
#38
jill8026 avatar

jill8026

Totally Zenned

Join Date:
May 2007
Posts:
461
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

Has this actually worked for anyone on 1.3.9H? I just tried implementing it and have had 5 more fake accounts created since....

Jill || I Love Zen Cart Templates || 2 Dogs Design
I Love To Help But Let's Keep It Public Please To Help Others!

9 Sep 2011, 1:50 AM
#39
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: Simple CSS/PHP AntiSpam solution for a contact form

jill8026:

Has this actually worked for anyone on 1.3.9H? I just tried implementing it and have had 5 more fake accounts created since....

I have it on 1.3.9h and it works like advertised. I have it on for many months and not a single fake account or email. Are you sure you have it installed correctly? Have you looked at the page with css off and filled in the form with the hidden field to see if it works like it's supposed to?


Zen Cart and it's community are the best!!

9 Sep 2011, 10:52 AM
#40
jill8026 avatar

jill8026

Totally Zenned

Join Date:
May 2007
Posts:
461
Plugin Contributions:
0

Re: Simple CSS/PHP AntiSpam solution for a contact form

Hi Lankeeyeankee....I did I checked it like 3 times and had another developer take a look for me as well....the field showed up fine when inline was disabled...field was renamed and everything was in place....it just wasn't working...I wound just putting a block for all China IP's on my server....

Jill || I Love Zen Cart Templates || 2 Dogs Design
I Love To Help But Let's Keep It Public Please To Help Others!