Friday, November 2, 2012

Re: preg_match Warning on Email

thank you for your reply chetan,... 
I'm steel getting an error: 
Warning (2): preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash [APP/controllers/invitations_controller.php, line 83]

this is my invitations model: 

    var $validate = array(
     'user_id' => array(
      'rule' => 'notEmpty',
      'message' => 'user must be valid',
     ),
'email'=> array(
                    'mustNotEmpty'=>array(
                        'rule' => 'notEmpty',
                        'message'=> 'Please enter email',
                        'last'=>true),
                    'mustBeEmail'=> array(
                        'rule' => array('email'),
                        'message' => 'Please enter valid email',
                        'last'=>true)                  
                    ),

 );

and this is what I have in a invitations controller: 
        $emails = array();
        
        if(!empty($this->data['Invitation']['emails']))
        {
          $raw_emails = explode(',', $this->data['Invitation']['emails']);
          foreach($raw_emails as $email)
          {
            $email = trim($email);
            if(preg_match('VALID_EMAIL', $email)) // This is where I'm getting an error... 
              $emails[] = $email;
          }

debug($email);

I placed the debug in,... and I'm reading test email in the view,... but steel getting an error 



On Friday, November 2, 2012 6:52:42 AM UTC-7, chetan varshney wrote:
For email validation you should use-

'email'=> array(
                    'mustNotEmpty'=>array(
                        'rule' => 'notEmpty',
                        'message'=> __('Please enter email'),
                        'last'=>true),
                    'mustBeEmail'=> array(
                        'rule' => array('email'),
                        'message' => __('Please enter valid email'),
                        'last'=>true)                 
                    ),

and for deep checking

'email'=> array(
                    'mustNotEmpty'=>array(
                        'rule' => 'notEmpty',
                        'message'=> __('Please enter email'),
                        'last'=>true),
                    'mustBeEmail'=> array(
                        'rule' => array('email', true),
                        'message' => __('Please enter valid email'),
                        'last'=>true)                 
                    ),



On Fri, Nov 2, 2012 at 7:05 PM, Chris <chri...@yahoo.com> wrote:
hi guys,... I'm getting this preg_match Warning on Email issue no matter what I do,.... 
can anyone help me please,.... 

Warning (2): preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash [APP/controllers/invitations_controller.php, line 83]

and this is what I have in a Model: 

    var $validate = array(
      'email' => array(
      'rule' => 'alphaNumeric',
      'required' => true,
      'allowEmpty' => false,
     ),
 );

thanks in advance,... 
chris

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake...@googlegroups.com.
To unsubscribe from this group, send email to cake-php+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 



--
Chetan Varshney
Ektanjali Softwares Pvt Ltd

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: