1

I would like to add Regex validation for that input given by user in OpenCart 2.0.0.0 module. I'm trying to validate it inside validate() in newmodule.php.

But I cant get a perfect output from preg_match(). After that I gone through on my regex pattern.

And there I found < is doing some serious problem. I got value entered by user by following function.

$this->request->post['variable'];

I printed that value. It looks exactly as user given. But < not matched in preg_match()...

Is there opencart doing any type of encoding like that works?

Following is my code

$var = $this->request->post['code_script'];
if(preg_match( "/<script>/s", $var ))
{
    $this->error['code'] = $this->language->get('error_invalid');
}
HDP
  • 4,005
  • 2
  • 36
  • 58
GoCool
  • 7
  • 1
  • 8
  • following is my preg_match( "/^ – GoCool Aug 19 '15 at 14:18
  • Please edit your question and add your regex along with the relevant block of code and what you are attempting to validate. It might also be helpful if you can supply two examples of user data, one which should validate and one which should fail. – But those new buttons though.. Aug 19 '15 at 20:06
  • your problem is not related to Opencart, it's regex expression, can try already asked question - 1 (http://stackoverflow.com/questions/4264678/regular-expression-to-match-html-p-tag-using-php) 2 (http://stackoverflow.com/questions/828870/php-regex-how-to-get-the-string-value-of-html-tag) 3 (http://stackoverflow.com/questions/9253027/get-everthing-between-tag-and-tag-with-php) – Nikhil Chaudhary Oct 15 '15 at 14:45

0 Answers0