Post by josed » Fri Dec 23, 2011 10:13 am

Estimated,

I want to validate the fax number.I already modificated these files:

catalog\controller\account\edit.php
catalog\controller\account\register.php

And I have created a function (validateFAX () ).

Code: Select all

		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate() && $this->validateFAX()) {
			$this->model_account_customer->editCustomer($this->request->post);
This function does not work. Where is my trouble????

I would appreciate any suggestion. Thanks a lot.

Newbie

Posts

Joined
Sat May 15, 2010 1:45 pm

Post by rph » Fri Dec 23, 2011 12:17 pm

No way to tell without seeing the validateFAX function (you should probably just roll it into the regular validate function anyway).

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by straightlight » Fri Dec 23, 2011 12:45 pm

If you already created the validateFAX(), there might be some confusion between the public function and private function. In this case, it would need to be set to private.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by josed » Sat Dec 24, 2011 7:20 am

straightlight wrote:If you already created the validateFAX(), there might be some confusion between the public function and private function. In this case, it would need to be set to private.
I defined the function like private:

Code: Select all

private function validateFAX(){
I have been a lot of time analyzing this situation. I have installed OC 1.5.1.3.

Any suggestion??

Thanks.

Newbie

Posts

Joined
Sat May 15, 2010 1:45 pm

Post by josed » Sat Dec 24, 2011 7:40 am

rph wrote:No way to tell without seeing the validateFAX function (you should probably just roll it into the regular validate function anyway).
The function is:

Code: Select all

private function validateFAX () {
    {
        $ncn = preg_replace( '/[^0-9A-Z]/i', '', $this->request->post['fax'] );
        if (preg_match('/X?[0-9]{8}[A-Z]/i', $ncn))
        {
              $ncn = preg_replace('/^X/i', '', $ncn);
              $stack = 'TRWAGMYFPDXBNJZSQVHLCKE';
              $pos = substr($ncn, 0, 8) % 23;
              if (strtoupper( substr($ncn, 8, 1) ) == substr($stack, $pos, 1) )
                  return TRUE;
        }
        else if (preg_match('/[A-HK-NPQS][0-9]{7}[A-J0-9]/i', $ncn))
        {
              $sum = 0;
              for ($i=2; $i<strlen($ncn)-1; $i+=2) {
                  $sum += substr($ncn, $i, 1);
              }

              for ($i=1; $i<strlen($ncn)-1; $i+=2) {
                  $t = substr($ncn, $i, 1) * 2;
                  $sum += ($t>9)?($t-9):$t;
              }
              $control = 10 - ($sum % 10);
              if ( substr($ncn, 8, 1) == $control ||
                   strtoupper(substr($ncn, 8, 1)) == substr('JABCDEFGHI', $control, 1 ))
                  return TRUE;
              }
              $this->error['fax'] = $this->language->get('error_fax');
              return FALSE;
        }
    }
I think that the trouble could be how is called the function:

Code: Select all

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate() && $this->validateFAX()) {
			unset($this->session->data['guest']);
			
			$this->model_account_customer->addCustomer($this->request->post);

			$this->customer->login($this->request->post['email'], $this->request->post['password']);
	  	  
	  		$this->redirect($this->url->link('account/success'));
    	}
I hope your help. Thank you

Newbie

Posts

Joined
Sat May 15, 2010 1:45 pm

Post by Qphoria » Sat Dec 24, 2011 10:40 am

Just tested it. The function works fine. I am not able to create an account if fax is empty and the error_fax variable gets set.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by josed » Tue Dec 27, 2011 10:05 am

Estimated,

The trouble is that I put anything like fax number and there not a validation. The function does not work.

Sorry, but I do not understand your solution. Can you explain me step by step?

P.S. : I am not native english speaker. I will try to understand your explanation.

Regards.

Newbie

Posts

Joined
Sat May 15, 2010 1:45 pm

Post by straightlight » Wed Dec 28, 2011 10:21 pm

Could you post your controller file as an attachment ? I will take a look at it.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 259 guests