Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 08-11-2008 10:50:47

kpryan
Member
Registered: 02-07-2005
Posts: 69

Simple Anti-Spam Deterence in Order Form

I have created a new custom field ( see topic 9419) that requires the customer to enter the last four digits of their telephone number by adding this code per the above post to ste_checkout.pl at about line 1792 where a check is made to see if all the required fields have been completed.

After foreach $line (@requiredfields){

I have added this line:

if ($line eq "tracking_customfour") {$line =~ s/[^0-9]//gs;}

This strips out everything except numbers. If there is only white space left then the programme errors out.

Even when I put numbers in the field CCP5.1 complains that I have not completed all the required fields. If I made custom four 'not required' then the problem goes away.

I cannot see what is wrong with the syntax of the expression above.

Any help gratefully received.

Offline

 

#2 08-11-2008 11:04:34

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Simple Anti-Spam Deterence in Order Form

I'm not entirely sure how Nick was implementing this... it might have been a version difference or something, but that just doesn't look right to me.  The regex is right, but I don't see how that implementation would work - it's stripping the non-numeric characters from the variable name, not the value.  I would try it a bit differently.  Remove the change you just did and look a little further down the code (maybe 10 lines or so) to find this:

Code:

} elsif ($line =~ /custom/ || $line =~ /other/) {

$fd_value = $q->param($line);

} else {

I would try changing that to:

Code:

} elsif ($line =~ /custom/ || $line =~ /other/) {

$fd_value = $q->param($line);

if ($line eq "tracking_customfour") {$fd_value =~ s/[^0-9]//gs;}

} else {

I haven't tested this at all, but the theory looks right.  Good luck!


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#3 08-11-2008 11:14:55

kpryan
Member
Registered: 02-07-2005
Posts: 69

Re: Simple Anti-Spam Deterence in Order Form

Works a treat!

Many thanks for your quick reply.

Regards,

K Ryan
KPR i-Services Ltd.

Offline

 

#4 08-11-2008 11:39:45

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Simple Anti-Spam Deterence in Order Form

You're very welcome.  As a side note, you can simplify that regex a bit, if you care to.  This will work just the same:

Code:

s/\D//g

Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#5 08-11-2008 13:58:04

celdirect
Member
From: UK
Registered: 04-01-2005
Posts: 782

Re: Simple Anti-Spam Deterence in Order Form

Hi,

What was the original post? Please.

Offline

 

#6 08-11-2008 15:30:55

rachaelseven
Member
From: Massachusetts, USA
Registered: 01-23-2006
Posts: 3169
Website

Re: Simple Anti-Spam Deterence in Order Form


Rachael Katz
- Custom Focusing Screens for DSLR Cameras

Offline

 

#7 08-11-2008 16:45:49

celdirect
Member
From: UK
Registered: 04-01-2005
Posts: 782

Re: Simple Anti-Spam Deterence in Order Form

Thank You

Offline

 

Board footer