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.'
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!