本文整理汇总了PHP中ContactForm::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP ContactForm::validate方法的具体用法?PHP ContactForm::validate怎么用?PHP ContactForm::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContactForm
的用法示例。
在下文中一共展示了ContactForm::validate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionContact
/**
* Displays the contact page
*/
public function actionContact()
{
$model = new ContactForm();
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
$chk = $model->validate();
if ($model->validate()) {
$name = $model->name;
$email = $model->email;
$textarea = $model->message;
$to = 'ranjita706@gmail.com';
$from = Yii::app()->params['adminEmail'];
$subject = 'Mail From JobStars Website:Contact Form ' . ucwords($name);
$mailBody = "\n\t\t\t\t\t <table dir='ltr'>\n\t\t\t\t\t<tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td style='padding:0;font-family:Segoe UI Semibold,Segoe UI Bold,Segoe UI,Helvetica Neue Medium,Arial,sans-serif;font-size:17px;color:#707070'>JobStar</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td style='padding:0;padding-top:6px;font-family:Segoe UI,Tahoma,Verdana,Arial,sans-serif;font-size:14px;color:#2a2a2a'>\n\t\t\t\t\t\t<ol>\t\t\t\n\t\t\t\t\t\t\t<li>Name : " . ucwords($name) . " </li>\n\t\t\t\t\t\t\t<li>Email Address : {$email} </li>\n\t\t\t\t\t\t\t<li>Mesaage : {$textarea} </li>\n\t\t\t\t\t\t</ol>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\n\t\t\t\t\t<tr><td style='padding:0;padding-top:25px;font-family:Segoe UI,Tahoma,Verdana,Arial,sans-serif;font-size:14px;color:#2a2a2a'>Thanks,</td></tr>\n\t\t\t\t\t<tr><td style='padding:0;font-family:Segoe UI,Tahoma,Verdana,Arial,sans-serif;font-size:14px;color:#2a2a2a'>JobStar Team</td></tr>\n\t\t\t\t\t</tbody>\n\t\t\t\t\t</table>";
//$headers = 'MIME-Version: 1.0' . "\r\n";
//$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
//$headers .= 'From: <'.$to.'>' . "\r\n";
//$headers .= 'Cc: ranjita706@gmail.com' . "\r\n";
//$chk = mail($to, $subject, $setText, $headers);
$this->mailsend($to, $from, $subject, $mailBody);
//die('hhh');
Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
$this->refresh();
}
}
$this->render('site/contact', array('model' => $model));
}
示例2: actionContact
/**
* Displays the contact page
*/
public function actionContact()
{
$model = new ContactForm();
$baseUrl = Yii::app()->createUrl('site/contact');
Yii::app()->user->setReturnUrl($baseUrl);
if (!Yii::app()->user->isGuest) {
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
$name = '=?UTF-8?B?' . base64_encode($model->name) . '?=';
$subject = '=?UTF-8?B?' . base64_encode($model->subject) . '?=';
$mail1 = Yii::app()->params['phpmail'];
$mail2 = Yii::app()->params['adminEmail'];
$body = "{$model->body}(Ответ присылать на {$model->email})";
$headers = "From: {$name} <{$mail1}>\r\n" . "Reply-To: {$mail2}\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/plain; charset=UTF-8";
mail(Yii::app()->params['adminEmail'], $subject, $body, $headers);
Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
$this->refresh();
}
}
$this->render('contact', array('model' => $model));
} else {
$this->redirect(array('site/login'));
}
}
示例3: actionIndex
public function actionIndex()
{
$this->partner_id = Yii::app()->params['partner_id'];
$file = dirname(__FILE__) . '/../../../../common/config/contacts.php';
if (!is_file($file)) {
throw new CHttpException(404, 'Файл контактов не найден' . $file);
}
$content = file_get_contents($file);
$arr = json_decode($content, true);
$partnerModel = Partners::model()->findByPk($this->partner_id);
if ($partnerModel == NULL) {
throw new CHttpException(404, 'Указанная запись не найдена');
}
$model = new ContactForm();
$model->setAttributes($arr);
if (isset($_POST['Partners']) || isset($_POST['ContactForm'])) {
$partnerModel->attributes = $_POST['Partners'];
$partnersuccess = $partnerModel->validate();
if ($partnersuccess) {
$partnerModel->update();
}
$config = array('vk' => $_POST['ContactForm']['vk'], 'twitter' => $_POST['ContactForm']['twitter'], 'facebook' => $_POST['ContactForm']['facebook'], 'odnokl' => $_POST['ContactForm']['odnokl']);
$model->setAttributes($config);
$confsuccess = $model->validate();
if ($confsuccess) {
$str = json_encode($config);
file_put_contents($file, $str);
}
if ($partnersuccess && $confsuccess) {
Yii::app()->user->setFlash('config', Yii::t('main', 'Your new options have been saved.'));
}
}
$this->render('index', array('model' => $model, 'partnerModel' => $partnerModel));
}
示例4: actionContact
/**
* Displays the contact page
*/
public function actionContact()
{
$model = new ContactForm();
if (isset($_POST['ContactForm'])) {
//echo "<pre>";
//print_r($_POST['ContactForm']);
//die('sss');
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
$name = $model->name;
$email = $model->email;
$textarea = $model->message;
/* $subject = '=?UTF-8?B?' . base64_encode($model->subject) . '?=';
$subject = 'Mail From JobStars Website:Contact Form';
$headers = "From: $name <{$model->email}>\r\n" .
"Reply-To: {$model->email}\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-type: text/plain; charset=UTF-8";
echo $sent = mail(Yii::app()->params['adminEmail'], $subject, $model->message, $headers);*/
$to = 'ranjita706@gmail.com';
$subject = 'Mail From JobStars Website:Contact Form from ' . ucwords($name);
echo $message = "\n\t\t\t\t\t <table dir='ltr'>\n\t\t\t\t\t<tbody>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td style='padding:0;font-family:Segoe UI Semibold,Segoe UI Bold,Segoe UI,Helvetica Neue Medium,Arial,sans-serif;font-size:17px;color:#707070'>JobStar</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td style='padding:0;padding-top:6px;font-family:Segoe UI,Tahoma,Verdana,Arial,sans-serif;font-size:14px;color:#2a2a2a'>\n\t\t\t\t\t\t<ol>\t\t\t\n\t\t\t\t\t\t\t<li>Name : " . ucwords($name) . " </li>\n\t\t\t\t\t\t\t<li>Email Address : {$email} </li>\n\t\t\t\t\t\t\t<li>Mesaage : {$textarea} </li>\n\t\t\t\t\t\t</ol>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\n\t\t\t\t\t<tr><td style='padding:0;padding-top:25px;font-family:Segoe UI,Tahoma,Verdana,Arial,sans-serif;font-size:14px;color:#2a2a2a'>Thanks,</td></tr>\n\t\t\t\t\t<tr><td style='padding:0;font-family:Segoe UI,Tahoma,Verdana,Arial,sans-serif;font-size:14px;color:#2a2a2a'>JobStar Team</td></tr>\n\t\t\t\t\t</tbody>\n\t\t\t\t\t</table>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
echo $chk = mail($to, $subject, $message, $headers);
die('hhh');
Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
$this->refresh();
}
}
$this->render('site/contact', array('model' => $model));
}
示例5: actionContact
/**
* Displays the contact page
*/
public function actionContact()
{
$model = new ContactForm();
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
//$attachment = Yii::app()->baseUrl.'/images/ban_admin.JPG';
$images = CUploadedFile::getInstancesByName('images');
$attachement = Yii::getPathOfAlias('webroot.files') . $model->file;
$mail = Yii::app()->Smtpmail;
$mail->SetFrom('admin@cads.mys', $model->name);
$mail->Subject = $model->subject;
$msg = $model->body . '<br />' . $model->email . '<br/>' . $model->name;
$mail->MsgHTML($msg);
$mail->CharSet = "UTF-8";
$mail->AddAddress('zmahazhir@gmail.com', "CADS Programmer");
$mail->AddAddress($model->email, "CADS Programmer");
$mail->AddAttachment($attachement);
if (!$mail->Send()) {
Yii::app()->user->setFlash('error', 'Error while sending email: ' . $mail->getError());
}
Yii::app()->user->setFlash('contact', 'You Email have been Sent');
$this->refresh();
}
}
$this->render('contact', array('model' => $model));
}
示例6: actionContact
/**
* Displays the contact page
*/
public function actionContact()
{
$model = new ContactForm();
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
//use 'contact' view from views/mail
$mail = new YiiMailer('contact', array('message' => $model->body, 'name' => $model->name, 'description' => 'Contact form'));
//render HTML mail, layout is set from config file or with $mail->setLayout('layoutName')
$mail->render();
//set properties as usually with PHPMailer
$mail->From = $model->email;
$mail->FromName = $model->name;
$mail->Subject = $model->subject;
$mail->AddAddress(Yii::app()->params['adminEmail']);
//send
if ($mail->Send()) {
$mail->ClearAddresses();
Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
} else {
Yii::app()->user->setFlash('error', 'Error while sending email: ' . $mail->ErrorInfo);
}
$this->refresh();
}
}
$this->render('contact', array('model' => $model));
}
示例7: actionContact
/**
* Displays the contact page
*/
public function actionContact()
{
$model = new ContactForm();
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
$headers = "From: {$model->email}\r\nReply-To: {$model->email}";
if (!Yii::app()->user->isGuest) {
$message = 'Пользователь # ' . Yii::app()->user->id . "\n";
}
$message .= $model->body;
$deps = ContactForm::getDepartments();
$message .= "\n\nСообщение отправлено в " . $deps[$model->departament];
$message .= "\n\nОбратная связь сайта " . $_SERVER['HTTP_HOST'];
mail(Yii::app()->params['adminEmail'], $model->subject, $message, $headers);
Yii::app()->user->setFlash('contact', 'Спасибо за обращение. Мы ответим Вам в ближайшее время.');
$this->refresh();
}
} else {
if (!Yii::app()->user->isGuest) {
$anketa = Anketa::model()->findByPk(Yii::app()->user->id);
$model->email = $anketa->email;
$model->name = $anketa->name;
}
}
$this->render('contact', array('model' => $model));
}
示例8: contactAction
public function contactAction(array $params)
{
//creating form entity
$form = new ContactForm($_POST);
//check if we have a flash message in get params
$flash_msg = isset($params['flash_msg']) ? $params['flash_msg'] : '';
//if form sent
if ($_POST) {
if ($form->validate()) {
$flash_msg = 'Message sent';
$email_body = "This is a message from {$form->getName()}, {$form->getEmail()} : {$form->getMessage()}";
//C:\xampp\mailoutput
mail('kap0sha@yandex.ru', 'Contact message', $email_body);
if ($_FILES['attachment']) {
$form->uploadAttachment();
}
} else {
$flash_msg = 'Fill in the fields';
}
//redirectt
header("Location: /index.php?controller=index&action=contact&flash_msg={$flash_msg}");
}
$data = array('form' => $form, 'message' => $flash_msg);
return $this->render('contact', $data);
}
示例9: actionContact
/**
* Displays the contact page
*/
public function actionContact()
{
$model = new ContactForm();
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
//$name='=?UTF-8?B?'.base64_encode($model->name).'?=';
//$subject='=?UTF-8?B?'.base64_encode($model->subject).'?=';
//$headers="From: $name <{$model->email}>\r\n".
// "Reply-To: {$model->email}\r\n".
// "MIME-Version: 1.0\r\n".
// "Content-Type: text/plain; charset=UTF-8";
//mail(Yii::app()->params['adminEmail'],$subject,$model->body,$headers);
//Yii::ankFileSave("contact-start");
//Yii::ankFileSave( $model->name );
//Yii::ankFileSave( $model->email );
//Yii::ankFileSave( $model->subject );
//Yii::ankFileSave( $model->body );
//Yii::ankFileSave("contact-stop");
AppCommon::sendEmail(Yii::app()->params['adminEmail'], "tw.in team", "contactus" . $model->subject, $model->email . "\n" . $model->name . "\n" . $model->body, array("contactus"));
Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
$this->refresh();
}
}
$this->render('contact', array('model' => $model));
}
示例10: actionContact
public function actionContact()
{
$model = new ContactForm();
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
$this->refresh();
}
}
$this->render('contact', array('model' => $model));
}
示例11: actionContact
/**
* Displays the contact page
*/
public function actionContact()
{
$model = CustomPage::LoadByRequestUrl('contact-us');
$this->pageTitle = $model->PageTitle;
$this->pageDescription = $model->meta_description;
$this->breadcrumbs = array($model->title => $model->RequestUrl);
$this->layout = "//layouts/column" . $model->column_template;
$ContactForm = new ContactForm();
if (isset($_POST['ContactForm'])) {
$ContactForm->attributes = $_POST['ContactForm'];
if ($ContactForm->validate()) {
$objEmail = new EmailQueue();
if (!Yii::app()->user->isGuest) {
$objCustomer = Customer::GetCurrent();
$objEmail->customer_id = $objCustomer->id;
$ContactForm->fromName = $objCustomer->mainname;
$ContactForm->fromEmail = $objCustomer->email;
}
$strHtmlBody = $this->renderPartial('/mail/_contactform', array('model' => $ContactForm), true);
$strSubject = Yii::t('email', 'Contact Us:') . $ContactForm->contactSubject;
$objEmail->htmlbody = $strHtmlBody;
$objEmail->subject = $strSubject;
$orderEmail = _xls_get_conf('ORDER_FROM', '');
$objEmail->to = empty($orderEmail) ? _xls_get_conf('EMAIL_FROM') : $orderEmail;
$objHtml = new HtmlToText();
//If we get back false, it means conversion failed which 99.9% of the time means improper HTML.
$strPlain = $objHtml->convert_html_to_text($strHtmlBody);
if ($strPlain !== false) {
$objEmail->plainbody = $strPlain;
}
if (!$objEmail->save()) {
Yii::log("Error creating email " . print_r($objEmail, true) . " " . print_r($objEmail->getErrors(), true), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
}
Yii::app()->user->setFlash('success', Yii::t('email', 'Message sent. Thank you for contacting us. We will respond to you as soon as possible.'));
//Attempt to use an AJAX call to send the email. If it doesn't work, the Download process will catch it anyway.
$jsScript = "\$.ajax({url:\"" . CController::createUrl('site/sendemail', array("id" => $objEmail->id)) . "\"});";
Yii::app()->clientScript->registerScript('sendemail', $jsScript, CClientScript::POS_READY);
} else {
Yii::app()->user->setFlash('error', Yii::t('cart', 'Please check your form for errors.'));
if (YII_DEBUG) {
Yii::app()->user->setFlash('error', print_r($ContactForm->getErrors(), true));
}
}
}
if (!Yii::app()->user->isGuest) {
$objCustomer = Customer::GetCurrent();
$ContactForm->fromName = $objCustomer->mainname;
$ContactForm->fromEmail = $objCustomer->email;
}
$this->canonicalUrl = $model->canonicalUrl;
$this->render('contact', array('ContactForm' => $ContactForm, 'model' => $model));
}
示例12: actionContact
/**
* Displays the contact page
*/
public function actionContact()
{
$model = new ContactForm();
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
sendHtmlEmail(app()->params['myEmail'], $model->name, $model->email, $model->subject, array('body' => $model->body, 'name' => $model->name, 'subject' => $model->subject, 'email' => $model->email), 'contact', 'main3');
Yii::app()->user->setFlash('success', '<strong>Message sent! </strong>Thank you for contacting us. We will respond to you as soon as possible.');
$this->refresh();
}
}
$this->render('contact', array('model' => $model));
}
示例13: actionContact
/**
* Displays the contact page
*/
public function actionContact()
{
$model = new ContactForm();
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
Yii::app()->crugemailer->sendMailContact($model);
Yii::app()->user->setFlash('success', 'Gracias por comunicarse. Nosotros le responderemos tan pronto como sea posible.');
$this->refresh();
}
}
$this->render('contact', array('model' => $model));
}
示例14: actionContact
/**
* Displays the contact page
*/
public function actionContact()
{
$model = new ContactForm();
if (isset($_POST['ContactForm'])) {
$model->attributes = $_POST['ContactForm'];
if ($model->validate()) {
$headers = "From: {$model->email}\r\nReply-To: {$model->email}";
mail("contato@isape.com.br", $model->subject, $model->body, $headers);
Yii::app()->user->setFlash('contact', 'Obrigado por entrar em contato.');
$this->refresh();
}
}
$this->render('contact', array('model' => $model));
}
示例15: actionContact
/**
* Displays contact page.
*
* @return mixed
*/
public function actionContact()
{
$model = new ContactForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.');
} else {
Yii::$app->session->setFlash('error', 'There was an error sending email.');
}
return $this->refresh();
} else {
return $this->render('contact', ['model' => $model]);
}
}