-2

嗨,我目前正在编辑我的 opencart 网站。我添加了一个新的文本框,他们需要在其中输入联系号码。

<b>Contact Number:</b><br />    
<input type="text" name="number" />

<b><?php echo $entry_enquiry; ?></b><br />
<textarea name="enquiry" cols="40" rows="10" style="width: 99%;"><?php echo $enquiry; ?></textarea>

这是获取文本框的代码:

if (isset($this->request->post['number'])) {
    $this->data['number'] = $this->request->post['number'];
} else {
    $this->data['number'] = '';
}

if (isset($this->request->post['enquiry'])) {
    $this->data['enquiry'] = $this->request->post['enquiry'];
} else {
    $this->data['enquiry'] = '';
}

我目前遇到问题,因为我需要结合数字和查询。这两个组合的文本框将是我邮件的 setText。

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
    $mail = new Mail();
    $mail->protocol = $this->config->get('config_mail_protocol');
    $mail->parameter = $this->config->get('config_mail_parameter');
    $mail->hostname = $this->config->get('config_smtp_host');
    $mail->username = $this->config->get('config_smtp_username');
    $mail->password = $this->config->get('config_smtp_password');
    $mail->port = $this->config->get('config_smtp_port');
    $mail->timeout = $this->config->get('config_smtp_timeout');             
    $mail->setTo($this->config->get('config_email'));
    $mail->setFrom($this->request->post['email']);
    $mail->setSender($this->request->post['name']);
    $mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
    $mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));
    $mail->send();

我能得到什么帮助吗?

4

2 回答 2

1

也许你想要这样的东西:

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
    $enquiry_and_contact = $this->request->post['enquiry'] . "\n\n"; 
    $enquiry_and_contact .= "Contact: " . $this->request->post['number']; 

    $mail = new Mail();
    $mail->protocol = $this->config->get('config_mail_protocol');
    $mail->parameter = $this->config->get('config_mail_parameter');
    $mail->hostname = $this->config->get('config_smtp_host');
    $mail->username = $this->config->get('config_smtp_username');
    $mail->password = $this->config->get('config_smtp_password');
    $mail->port = $this->config->get('config_smtp_port');
    $mail->timeout = $this->config->get('config_smtp_timeout');             
    $mail->setTo($this->config->get('config_email'));
    $mail->setFrom($this->request->post['email']);
    $mail->setSender($this->request->post['name']);
    $mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
    $mail->setText(strip_tags(html_entity_decode($enquiry_and_contact, ENT_QUOTES, 'UTF-8')));
    $mail->send();
}
于 2013-10-06T08:30:47.827 回答
0

使用连接运算符 ( .)

改变这个

$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));

$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'].$this->request->post['number'], ENT_QUOTES, 'UTF-8')));

编辑:

$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry']." ".$this->request->post['number'], ENT_QUOTES, 'UTF-8')));
于 2013-10-06T08:20:37.153 回答