我在php页面下面有一个删除查询,用户输入一个分机号,并从数据库中删除该条目。
名称,电子邮件,分机,电话,部门通过输入数据库成员的分机号码删除整行。
现在我安装了phpmailer并正在为此工作,它正在向IT@sadsa.com发送邮件,但我试图让它在将成员从数据库中删除之前将邮件发送到另一个地址,具体取决于部门他们在。
EG。如果他们在销售部门,那么电子邮件必须发送到sales@sadsa.com
和IT@sada.com
,如果他们在管理部门,那么邮件必须发送到Admin@sadsa.com
和IT@asdas.com.
我目前的代码如下:
delete.php(用户输入要删除的分机号码的php页面)
<?php
require ("database.php");
session_start();
if (!isset($_SESSION['CheckLogin'])) { header("Location: login.php"); }
$this_user_ext =$_REQUEST['extension'];
// sending query
mysql_query("DELETE FROM users WHERE extension = '$this_user_ext'")
or die(mysql_error());
if($_POST['action']) {
include('maildelete.php');
$extension=$_POST['extension'];
header("Location: index.php");
}
?>
<center><form action="" method="post">
Enter 4 Digit Extension Number :<br><input type="text" name="extension"><br><input type="submit" name="action" value="Delete!">
<br> <br>
<h3>
<a href="index.php"> Main Menu </a>
</h3>
</form>
</center>
maildelete.php(这是将邮件发送到IT@sad.com的脚本)
<?php
$extension = $_POST['extension'];
require 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.titan-networks.co.za"; // SMTP server // enables SMTP debug information
$mail->SMTPAutoTLS = false;
$mail->SMTPSecure = false;
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.titan-networks.co.za"; // sets the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "jurgen@titan-networks.co.za"; // SMTP account username
$mail->Password = "****"; // SMTP account password
$mail->From = "no-reply@alpinemotors.co.za";
$mail->FromName = "Extension List";
$mail->AddAddress('jurgen@titan-networks.co.za', "");
$mail->isHTML(true);
$mail->Subject = 'Extension Deleted';
$mail->Body = "Extension Number " . $extension . " was removed from the Extension List";
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Email Sent Successfully!';
?>