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.
And here is what the email that gets delivered to me looks like:
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.