1
Chainsaw
Bug in Formulaire module code? PHP guru help!
  • 2004/1/14 1:59

  • Chainsaw

  • Quite a regular

  • Posts: 304

  • Since: 2003/9/28


Hi there.

I've installed Formulaire which is a multiple form module (allows you to create many submit forms which can be delivered to email address, XOOPS PM or XOOPS Group PM).

There is a bug in the module which prevents the use of New Zealand email address. eg myname@mydomain.co.nz

I've tried creating a form to send to nzchainsaw @ hotmail . com and that worked. But if I type in (for example) myname@mydomain.co.nz it says this is an incorrect email address!

I've checked the codes at admin/formindex.php and found this portion which could be the cause of our problem

function addform()
{
    global 
$xoopsDB$HTTP_POST_VARS$myts$eh;
    
$title $myts->makeTboxData4Save($HTTP_POST_VARS["desc_form"]);
    
$admin $myts->makeTboxData4Save($HTTP_POST_VARS["admin"]);
    
$groupe $myts->makeTboxData4Save($HTTP_POST_VARS["groupe"]);
    
$email $myts->makeTboxData4Save($HTTP_POST_VARS["email"]);
    
$expe $myts->makeTboxData4Save($HTTP_POST_VARS["expe"]);
    if (empty(
$title)) {
        
redirect_header("formindex.php"2_MD_ERRORTITLE);
    }
    if((!empty(
$email)) && (!eregi("^[a-z0-9.-_]+@[a-z0-9]{2,}[.][a-z]{2,3}$",$email))){
        
redirect_header("formindex.php"2_MD_ERROREMAIL);
    }
    if (empty(
$email) && empty($admin) && $groupe=="0" && empty($expe)) {
        
redirect_header("formindex.php"2_MD_ERRORMAIL);
    }


Can someone tell me what is this code suppose to do?

if((!empty($email)) && (!eregi("^[a-z0-9.-_]+@[a-z0-9]{2,}[.][a-z]{2,3}$",$email))){

As far as I can decipher it is along the line of

if not empty $email and ......

How can I change it to accept a @domain.co.nz address?

2
Chainsaw
Re: Bug in Formulaire module code? PHP guru help!
  • 2004/1/14 2:34

  • Chainsaw

  • Quite a regular

  • Posts: 304

  • Since: 2003/9/28


OK I think I can see the problem (correct me if I am wrong).

The above code only covers an email address with two suffix after the @

ie me@aaa.bbb

If I enter an address with three suffixes it won't work?

ie me@aaa.bbb.ccc

3
philroy
Re: Bug in Formulaire module code? PHP guru help!
  • 2004/1/14 2:34

  • philroy

  • Friend of XOOPS

  • Posts: 107

  • Since: 2003/8/23


It's validating the email address that the person enters.....making sure there's an address entered and that it contains appropriate characters, including the '@' symbol.

It's not a perfect check (it can't possibly tell if the address really is a true web address of somebody), but it's good to have it check their entry.

Phil

4
Chainsaw
Re: Bug in Formulaire module code? PHP guru help!
  • 2004/1/14 2:44

  • Chainsaw

  • Quite a regular

  • Posts: 304

  • Since: 2003/9/28


That make sense.

Assuming that only the administrators can create a form (and therefore more likely to enter a correct email address), how do I disable this check?

5
philroy
Re: Bug in Formulaire module code? PHP guru help!
  • 2004/1/14 3:00

  • philroy

  • Friend of XOOPS

  • Posts: 107

  • Since: 2003/8/23


Carefully remove the code...but I wouldn't.....we're all human and sometimes make mistakes on data entry. It's harmless, so I'd leave it.

Doing a search of google for "validating email php" brings up some sites that might help you if you feel the validation isn't working, such as...
http://www.zend.com/tips/tips.php?id=8&single=1

Phil

6
Chainsaw
Re: Bug in Formulaire module code? PHP guru help!
  • 2004/1/14 3:05

  • Chainsaw

  • Quite a regular

  • Posts: 304

  • Since: 2003/9/28


K mind you I'm not a PHP programmer but I know rule number one (keep a backup of original in case of FUBAR).

I change the code from
if((!empty($email)) && (!eregi("^[a-z0-9.-_]+@[a-z0-9]{2,}[.][a-z]{2,3}$",$email))){


to

if((!empty($email)) && (!eregi("^[a-z0-9.-_]+@[a-z0-9]{2,}[.][a-z]{2,3}[.][a-z]{2,3}$",$email))){


And that seem to work with a .co.nz address. Can anyone see any problem with what I've done?

7
Chainsaw
Re: Bug in Formulaire module code? PHP guru help!
  • 2004/1/14 3:12

  • Chainsaw

  • Quite a regular

  • Posts: 304

  • Since: 2003/9/28


Quote:

philroy wrote:
Carefully remove the code...but I wouldn't.....we're all human and sometimes make mistakes on data entry. It's harmless, so I'd leave it.

Doing a search of google for "validating email php" brings up some sites that might help you if you feel the validation isn't working, such as...
http://www.zend.com/tips/tips.php?id=8&single=1

Phil



Ahhh thanks for that URL. I checked it out but it looks like the other one ie 2 suffix check after the @

Some countries uses 3 suffixes eg .com.au (australia), .co.uk (for UK) and .co.nz (for New Zealand).

8
philroy
Re: Bug in Formulaire module code? PHP guru help!
  • 2004/1/14 3:24

  • philroy

  • Friend of XOOPS

  • Posts: 107

  • Since: 2003/8/23


Quote:
Some countries uses 3 suffixes eg .com.au (australia), .co.uk (for UK) and .co.nz (for New Zealand).


Being a Kiwi myself, I kinda know that one

This helpful page...
http://www.developer.com/lang/php/article.php/3290141
includes code that checks for an authentic domain.

Phil

9
philou
Re: Bug in Formulaire module code? PHP guru help!
  • 2004/7/10 9:06

  • philou

  • Quite a regular

  • Posts: 384

  • Since: 2002/5/6 8


it's right... and also you can use this relar expression :
^[_a-z0-9.-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$

10
Mithrandir
Re: Bug in Formulaire module code? PHP guru help!

why not just use the core function checkEmail($email,$antispam = false) ?

include/functions.php line 281

Login

Who's Online

224 user(s) are online (146 user(s) are browsing Support Forums)


Members: 0


Guests: 224


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits