dongpigui8898 2013-10-06 00:17
浏览 14
已采纳

在PHP中合并邮件的两个文本框值

Hi I am currently editing my opencart website. I added a new text box wherein they need to input a contact number.

<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>

This is the code in order to get the text boxes:

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'] = '';
}

I am currently in problem because I need to combine number and enquiry. The two combined text boxes will be the setText of my mail.

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();

Any help I can get?

展开全部

  • 写回答

2条回答 默认 最新

  • dqy92287 2013-10-06 00:30
    关注

    Perhaps you want something like this:

    if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
        $enquiry_and_contact = $this->request->post['enquiry'] . "
    
    "; 
        $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();
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?