I am creating a simple helpdesk where people will send their trouble tickets and i want the email to be sent to the support 1 which i can do , but there are two specific categories which when selected i want the email to be send to a support 2 and not support 1
pls help me the code below its only sending to the support one but i want it to work in a way that when Feitware is selectected it only send to support 2
pls help
<?php
include("connection.php");
//Check for required fields from query.html
if (!$_POST[name]|!$_POST[email]|!$_POST[branch]|!$_POST[ext]|$_POST[category] == 'NS'|!$_POST[subject]|!$_POST[problem])
die('You did not fill in a required field');
// Define variables
$IP=$_SERVER['REMOTE_ADDR'];
//echo $IP;
$date=mktime(date(H),date(i),date(s),date(m),date(d),date(Y));
// Strip all HTML tags
$name=strip_tags($_POST[name]);
$email=strip_tags($_POST[email]);
$branch=strip_tags($_POST[branch]);
$ext=strip_tags($_POST[ext]);
$category=$_POST[category];
$subject=strip_tags($_POST[subject]);
$problem=strip_tags($_POST[problem]);
$status="3"; //3-Active,2-Busy,1-Approval,0-Closed
//Add the information to the users tables
$submit = "insert into query (name,email,branch,ext,date_add,category,subject,problem,status,ip)
values ('$name','$email','$branch','$ext','$date','$category','$subject','$problem','$status','$IP')";
mysql_query($submit);
// Get ticket number
// Get ticket number
$search="select ticket from query where date_add='$date'";
$tic=mysql_fetch_array(mysql_query($search));
$msg="<html><head><title>Query logged</title></head>";
$msg.="<body><h3>Query logged</h3><table>";
$msg.="<tr><td><b>Ticket:</b></td> <td>$tic[ticket]</td></tr>";
$msg.="<tr><td><b>Name:</b></td> <td>$name</td></tr>";
$msg.="<tr><td><b>E-mail:</b></td> <td>$email</td></tr>";
$msg.="<tr><td><b>Branch:</b></td> <td>$branch</td></tr>";
$msg.="<tr><td><b>Extension:</b></td> <td>$ext</td></tr>";
$msg.="<tr><td><b>Category:</b></td> <td>$category</td></tr>";
$msg.="<tr><td><b>Subject:</b></td> <td>$subject</td></tr></table>";
$msg.="<br><b>Description:</b><br>";
$msg.="$problem";
$msg.="</body></html>";
if ($_POST[category] == 'Freightware'){
Header("Location:querylogged.php");
// E-mail function
require("mail/class.phpmailer.php");
require("mail/class.smtp.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "10.0.0.3";
$mail->From = "testmail@thikho.co.za";
$mail->FromName = "Thikho IT Helpdesk";
$mail->Sender = "\"Thikho IT Helpdesk\" ";
$mail->IsHTML(true);
//$mail->CharSet = "iso-8859-1";
$mail->AddAddress($email);
$mail->AddAddress("testmail@gmail.com");
$mail->Subject = "New query - Ticket no. $tic[ticket]";
$mail->Body = $msg;
//$mail->AltBody = "Hi, \n\n A query has been logged \n\nregards, \n\n Thikho IT Helpdesk!";
if(!$mail->Send()) // Now we send the email and check if it was send or not.
{
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
else
{
echo 'Message has been sent 1.';
}
echo mysql_error();
}else{
// E-mail function
//require("mail/class.phpmailer.php");
//require("mail/class.smtp.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "10.0.0.3";
$mail->From = "testmail@thikho.co.za";
$mail->FromName = "Thikho IT Helpdesk";
$mail->Sender = "\"Thikho IT Helpdesk\" ";
$mail->IsHTML(true);
//$mail->CharSet = "iso-8859-1";
$mail->AddAddress($email);
$mail->AddAddress("testmail@thikho.co.za");
$mail->Subject = "New query - Ticket no. $tic[ticket]";
$mail->Body = $msg;
//$mail->AltBody = "Hi, \n\n A query has been logged \n\nregards, \n\n Thikho IT Helpdesk!";
if(!$mail->Send()) // Now we send the email and check if it was send or not.
{
echo 'Message was not sent 2.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
else
{
echo 'Message has been sent.';
}
echo mysql_error();
?>