вывод телефона в сообщение при отправки письма через форму

252
16 ноября 2017, 05:35

Есть форма отправки сообщения, есть поле email, из него нужно сделать поле с телефоном, и что бы телефон был в письме вместе с сообщением:

    $json = array();
    if ($this->request->server['REQUEST_METHOD'] == 'POST') {
        if ((utf8_strlen($this->request->post['cf_email']) < 2) || (utf8_strlen($this->request->post['cf_email']) > 60)) {
            $json['error'] = $this->language->get('error_email');
        }
        if ((utf8_strlen($this->request->post['cf_text']) < 5) || (utf8_strlen($this->request->post['cf_text']) > 1000)) {
            $json['error'] = $this->language->get('error_message');
        }
        if (empty($this->session->data['captcha_contact_form']) || ($this->session->data['captcha_contact_form'] != $this->request->post['cf_captcha'])) {
            $json['error'] = $this->language->get('error_verification');
        }
        unset($this->session->data['captcha_contact_form']);
        if (!isset($json['error'])) {
        $mail = new Mail();
        $mail->protocol = $this->config->get('config_mail_protocol');
        $mail->parameter = $this->config->get('config_mail_parameter');
        $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
        $mail->smtp_username = $this->config->get('config_mail_smtp_username');
        $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
        $mail->smtp_port = $this->config->get('config_mail_smtp_port');
        $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');           
        $mail->setTo($this->config->get('config_email'));
        $mail->setFrom($this->request->post['cf_email']);
        $mail->setSender(html_entity_decode($this->request->post['cf_name'], ENT_QUOTES, 'UTF-8'));
        $mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['cf_name']), ENT_QUOTES, 'UTF-8'));
        $mail->setText($this->request->post['cf_text']);
        $mail->send();
            $json['success'] = $this->language->get('text_success');
        }
    }
    $this->response->addHeader('Content-Type: application/json');
    $this->response->setOutput(json_encode($json));
}
`

Изменил:

 if `((utf8_strlen($this->request->post['cf_phone']) < 2) || 
 (utf8_strlen($this->request->post['cf_phone']) > 60)) {
            $json['error'] = $this->language->get('error_phone');
        }`

Но как заставить его выводить сюда $mail->setText($this->request->post['cf_text']);?

READ ALSO
приватный метод область видимости

приватный метод область видимости

Почему возникает ошибка PHP Fatal error: Class 'user\login\SystemCommand\DateTime' not found in

245
Php MySql на ноуте работает, на телефоне - нет

Php MySql на ноуте работает, на телефоне - нет

На ноуте установлен серве XAMPP и он работает вполне отлично, на телефоне https://bitbucketorg/esminis/server/wiki/Home из этой серии Server for PHP (PHP) и MariaDB Server (MariaDB)

228
Авторизация на сайте по кукам

Авторизация на сайте по кукам

Скажите пожалуйста, вот у меня есть форма авторизации, классика логин и пароль, и можно как-то один раз авторизоваться по логину и паролю,...

302
Пропадает Google reCAPTCHA при аякс запросе

Пропадает Google reCAPTCHA при аякс запросе

Доброго времени суток, у меня на главной странице есть форма отправки вопроса, к ней подключена обычная google recaptcha v2, всё работает отлично,...

320