duan198811 2014-08-06 22:07
浏览 35
已采纳

获取表单提交ID并输入phpmailer电子邮件

I created a ticket system that does the following: (FYI st_id is the id in my table)

  • User fills out form and hits submit
  • After submit it takes the info from the form and emails to me via phpmailer
  • During the email process it also enters all info into a support ticket table

The problem I'm having is I use the support_ticket tables st_id as the ticket number.

When a user fills out the form, the entry is emailing all the form data first and not acquiring the st_id number.

I need the st_id number to show in the email.

So I'm looking for help on how to get the st_id / ticket number to email with the other data.

Here is what my database looks like.

enter image description here

And here is what the email that gets delivered to me looks like:

enter image description here

In the action script I have the following.

// form data

$ticket_type    = $_POST['ticket_type'];
$subject        = $_POST['subject'];
$content        = $_POST['content'];
$user_id        = $_POST['user_id'];
$unit           = $_POST['unit'];
$first_name     = $_POST['first_name'];
$last_name      = $_POST['last_name'];
$email          = $_POST['email'];
$phone          = $_POST['phone'];
$st_id          = $_POST['st_id'];

// query



$addticket = DB::getInstance()->insert('support_ticket', array(

    //'st_id'           => $st_id,
    'ticket_type'   => $ticket_type,
    'subject'       => $subject,
    'content'       => $content,
    'user_id'       => $user_id,
    'unit'          => $unit,
    'first_name'    => $first_name,
    'last_name'     => $last_name,
    'email'         => $email,
    'phone'         => $phone

));

Then the email section:

User::sendNewticket('myemail@fake.com', 'Subject of email', '<strong>'.Input::get('first_name') .' '.Input::get('last_name').'</strong>, from unit <strong>'.Input::get('unit').',</strong> ' . 'has called in a maintenance ticket for the following:<br><br>

<strong>Ticket Number:</strong> '.Input::get('st_id') .'<br><br>
<strong>Ticket Type:</strong> '.Input::get('ticket_type') .'<br><br>
<strong>Subject:</strong> '.Input::get('subject') .'<br><br>
<strong>Message:</strong> '.Input::get('content') .'<br><br>
....etc

I need to find a way to get <strong>Ticket Number:</strong> '.Input::get('st_id') .' this to work.

I think I need to write a query that grabs the st_id from the table and Posts it to the email script before the email is sent, but again not sure how to get that to work.

Any ideas or solutions would be much appreciated. If you need me to post more code let me know. I tried to keep it to a minimum of what was relevant.

  • 写回答

1条回答 默认 最新

  • doulang7699 2014-08-07 14:13
    关注

    Under this Insert query I added:

    $addticket = DB::getInstance()->insert('support_ticket', array(
    
        //'st_id'           => $st_id,
        'ticket_type'   => $ticket_type,
        'subject'       => $subject,
        'content'       => $content,
        'user_id'       => $user_id,
        'unit'          => $unit,
        'first_name'    => $first_name,
        'last_name'     => $last_name,
        'email'         => $email,
        'phone'         => $phone
    
    ));
    
    $st_id = DB::getInstance()->lastInsertId();
    

    In my DB.php class file I had to add this:

    public function lastInsertId() {
    return $this->_pdo->lastInsertId();
    }
    

    Then finally in my email section I simply added this to retrieve the Ticket number.

    Ticket Number: '.$st_id.'
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳