/** * Show Form */ public function actionIndex() { $model = new ContactUs(); if (isset($_POST['ContactUs'])) { $model->attributes = $_POST['ContactUs']; if ($model->save()) { // Do we need to email? if (Yii::app()->params['contactusemail']) { // Build Message $message = Yii::t('contactus', "New Contact Us Form Submitted<br /><br />\n\t\t\t\t\t\t\t\t\t\t\t\t Id: {id}<br />\n\t\t\t\t\t\t\t\t\t\t\t\t\tBy: {name}<br />\n\t\t\t\t\t\t\t\t\t\t\t\t\tEmail: {email}<br />\n\t\t\t\t\t\t\t\t\t\t\t\t\tSubject: {subject}<br />\n\t\t\t\t\t\t\t\t\t\t\t\t\t========================<br />\n\t\t\t\t\t\t\t\t\t\t\t\t\t{msg}<br />\n\t\t\t\t\t\t\t\t\t\t\t\t\t========================<br /><br />\n\t\t\t\t\t\t\t\t\t\t\t\t\tRegards, the {team} Team.", array('{id}' => $model->id, '{name}' => $model->name, '{email}' => $model->email, '{subject}' => $model->subject, '{msg}' => $model->content, '{team}' => Yii::app()->name)); $email = Yii::app()->email; $email->subject = Yii::t('contactus', 'New Contact Us Form: {subject}', array('{subject}' => $model->subject)); $email->to = Yii::app()->params['emailout']; $email->from = $model->email; $email->replyTo = Yii::app()->params['emailout']; $email->message = $message; $email->send(); } Yii::app()->user->setFlash('success', Yii::t('contactus', 'Thank You. The form submitted successfully.')); $model = new ContactUs(); } } // If we are a member then fill in if (Yii::app()->user->id) { $user = Members::model()->findByPk(Yii::app()->user->id); if ($user) { $model->name = $user->username; $model->email = $user->email; } } $this->render('index', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new ContactUs(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['ContactUs'])) { $model->attributes = $_POST['ContactUs']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->contact_id)); } } $this->render('create', array('model' => $model)); }
/** * index, default action **/ public function index() { $this->strTemplateName = 'home'; if ($_POST && $_POST['mode'] == 'submit') { $_POST['dob'] = sprintf('%s-%02s-%02s', (int) $_POST['dob-yyyy'] ? $_POST['dob-yyyy'] : '', (int) $_POST['dob-mm'] ? $_POST['dob-mm'] : '', (int) $_POST['dob-dd'] ? $_POST['dob-dd'] : ''); //die($_POST['dob']); list($this->blnSuccess, $this->aryErrorMsgList, $this->aryRequest) = $this->filter($_POST, __METHOD__); if ($this->blnSuccess) { $objContactUs = new ContactUs($this->aryRequest); list($intContactUsID, $blnSendEmail) = $objContactUs->save(); if ($intContactUsID && $blnSendEmail) { header('Location: ?action=thankyou'); exit; } } else { $this->_setBackDob($_POST); } } }