Exemplo n.º 1
0
 public function emailAction()
 {
     global $mySession;
     $this->_helper->layout->setLayout('myaccount');
     $db = new Db();
     $myform = new Form_Referfriends();
     $this->view->myform = $myform;
     if ($this->getRequest()->isPost()) {
         //echo "is post"; die;
         $request = $this->getRequest();
         $myform = new Form_Referfriends();
         if ($myform->isValid($request->getPost())) {
             $dataForm = $myform->getValues();
             $friendsemailid = explode(",", $dataForm['friendsemailid']);
             //prd($friendsemailid);
             //for($i=0; $i<count($friendsemailid); $i++)
             foreach ($friendsemailid as $key1 => $value1) {
                 if (trim($value1) != "") {
                     //if(!preg_match('^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}(\.[a-zA-Z]{2,3})?(\.[a-zA-Z]{2,3})?^', trim($value1)))
                     if (!preg_match('/^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\\.[a-zA-Z]{2,4}(\\.[a-zA-Z]{2,3})?(\\.[a-zA-Z]{2,3})?$/', trim($value1))) {
                         $mySession->errorMsg = "Enter a valid email address";
                         //$this->render('referfriends');
                         $this->_redirect('myaccount/referfriends');
                         //$invalid_ids=$invalid_ids.",".$invalidemailId;
                     }
                 }
             }
             //for($i=0; $i<count($friendsemailid); $i++)
             //				{
             //					if(!eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}(\.[a-zA-Z]{2,3})?(\.[a-zA-Z]{2,3})?$', trim($friendsemailid[$i])))
             //					{
             //						echo "aaa"; die;
             //					}
             //					else
             //					{
             //						$mySession->errorMsg="Enter a valid email address";
             //						$this->render('referfriends');
             //					}
             //				}
             $myObj = new Myaccountdb();
             $data = $myObj->emailfriends($dataForm);
             if ($data == 1) {
                 $mySession->errorMsg = "Email sent to your friends";
                 $this->_redirect('myaccount/activecampaign');
             }
         } else {
             //echo "is valid else";
             $this->view->myform = $myform;
             $this->render('referfriends');
         }
     } else {
         //echo "get request else";
         $this->_redirect('myaccount/referfriends');
     }
 }