Jump to content

Invalid e-mail address, can not login


Recommended Posts

Hello!

 

I've suddenly got an error that says:

 

There is 1 error :

 

Invalid e-mail address

 

when customers try to log in, create a new account or sign up to the newsletter.

The same error message occurs when I try to log into the back office.

 

Prestashop version is 1.4.8.2 and the server has been upgraded to PHP 5.3.3

I have not changed anything in codes and the store has worked fine since July 2012. The error occured late in February 2013.

 

 

 

Anybody have an idea what this could be, please?

 

Regards

Nils

Edited by Nilsemann2 (see edit history)
Link to comment
Share on other sites

ps uses class/Validate.php

 

this function: at or around line 40

 /**
* Check for e-mail validity
*
* @param string $email e-mail address to validate
* @return boolean Validity is ok or not
*/
public static function isEmail($email)
{
 return !empty($email) && preg_match('/^[a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+[._a-z\p{L}0-9-]*\.[a-z0-9]+$/ui', $email);
}

 

check that the code above is the same as posted.

check that the file date (using ftp) has not been recently updated.

check that a module has not installed a class override? -->override/classes (look for Validate.php)

Link to comment
Share on other sites

Thanks for the reply.

 

elpatron: The code in Validate.php is the same one that you posted.

validated.php has the same date as the rest of the files and is unaffected since 07/24/12. That was when the system was installed.

I can not find Validate.php in override/classes

Link to comment
Share on other sites

No nothing in override/controllers either, just the index-file.

I will check for file updates.

 

Do you think this error may have something to do with that the server's php version was upgraded recently?

 

try this (check compatibility)

 

back office-->tools-->configuration information

 

scroll to the bottom

 

should look like this:

03.14.2013-10.55.21.png

http://screencast.com/t/04MPCslg1DSL

Edited by elpatron (see edit history)
Link to comment
Share on other sites

well...that is a mess....as you can guess...guessing your problem was difficult enough...now even more so :)

 

you should just go look for updated files...

 

and it may not hurt to contact your hosting company....about php upgrade....

 

also you could create a subomain and additional db, place a fresh 1.4.8 prestashop there and try installing it, see if it warns you of incompatibility issues.

Link to comment
Share on other sites

I have now tried to install the fresh version of PS 1.4.8.2 and a fresh database on the same server.

 

As you can see below, both the system compatibility and database configuration are OK, but when it comes to the shop configuration I get the same error "This e-mail address is invalid!"

 

Strange error, but this has to be something with the server configuration to do since I've installed the same version and enjoyed a working shop for over half a year? Or what do you think?

 

printscreen.png

Edited by Nilsemann2 (see edit history)
Link to comment
Share on other sites

just an experiment:

 

replace/create the file in override/classes/Validate.php with this content:

 

<?php
class Validate extends ValidateCore
{
public static function isEmail($email)
{
 return !empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL);
}	  
}

Link to comment
Share on other sites

just an experiment:

 

replace/create the file in override/classes/Validate.php with this content:

 

<?php
class Validate extends ValidateCore
{
public static function isEmail($email)
{
 return !empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL);
}	  
}

 

Good thinking, but unfortunately it does not work, get the same error.

Link to comment
Share on other sites

interesting, let's see at least what we have passed in the validation method. instead of that return place

CODE]echo $email; exit;[/code]

 

public static function isEmail($email)
{
echo $email;exit;
}  

 

maybe here the email variables arrives empty

Link to comment
Share on other sites

That's very nice of you to offer, thank you, maybe we can so that later?

 

But for now I've discovered that I can log in as customer and also in the BO if I use return true in override/classes/Validate.php

 

<?php
class Validate extends ValidateCore
{
public static function isEmail($email)
{
return true;

}		
}

 

However this does not solve the problem because I have not changed anything in Validate.php since I installed the system.. and now no new e-mails gets validated.

Could it has something to do with the PHP upgrade and its handling of e-mail validation?

Edited by Nilsemann2 (see edit history)
Link to comment
Share on other sites

Just to confirm, if you return true, the account creation works correctly?

If yes you just need to see what is wrong with the regex that validates the email or try to implement another way.

 

However the best solution is to find the reason of the issue.

Link to comment
Share on other sites

I can confirm that.

 

When I create a new account or login as an existing customer, everything works correctly.

Even when I login to the BO, it works :-)

 

But now I can write what ever I want in the email field when I create a new customer. That is not optimal.

 

Here is the code in Validation.php who makes the error happen:

 

public static function isEmail($email)
{
	return !empty($email) && preg_match('/^[a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]+[.a-z\p{L}0-9!#$%&\'*+\/=?^`{}|~_-]*@[a-z\p{L}0-9]+[._a-z\p{L}0-9-]*\.[a-z0-9]+$/ui', $email);
}

 

I cant see anything wrong here, can you?

I even replaced Validate.php with the orginal file today, but got the same error.

 

Edit:

I have a theory that this can have something to do with the preg_match() function. It fails in PHP 5.3.3 and returns false..

Edited by Nilsemann2 (see edit history)
Link to comment
Share on other sites

it seems so, but what's strange is that even with the filter I sent last time:

 

return !empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL);

it's not working.

Maybe this is just as a shortcode for preg_match

 

I just found something here:

http://bytes.com/topic/php/answers/780352-weird-issue-php-preg_match

read the last reply

 

meantime you can use a raw php check by checking if the email has @ at least a . for the domain

Link to comment
Share on other sites

×
×
  • Create New...