保存记录并通过php中的电子邮件通知负责人 [英] Save record and notify responsible person through email in php

查看:100
本文介绍了保存记录并通过php中的电子邮件通知负责人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在尝试将记录保存到improve_plan表中,然后向负责人发送电子邮件。从组合框中选择Responsible2后,程序会将Responsible2保存到improve_plan表中,然后向该人发送电子邮件通知。但是,我无法保存和发送电子邮件。请指教。非常感谢。



 error_reporting(E_ALL ^ E_NOTICE); 
$ con = mysql_connect( localhost user );
if (!$ con){
die( 无法连接: .mysql_error());
}
mysql_select_db( pq,$ con);
$ sql = SELECT * FROM user ;
$ rs = mysql_query($ sql) die(mysql_error());
echo < select name =' responsible2' >中;
while($ row = mysql_fetch_array($ rs)){
echo < option value =。$ row [' 电子邮件']。 >。$ row [' Position']。 < /选项>中;

$ responsible2 = $ row [' Position'];
echo $ responsible2 ;
}
mysql_free_result($ rs);
< / select>;

if(isset($ _ POST [' Notify2'])){

$ responsible2 = $ _ POST [' responsible2'];
$ progressid = $ _ SESSION [' Progressid'];
echo $ progressid ;

mysql_query( INSERT INTO improvement_plan(Responsible2,Progressid)VALUES(' $ responsible2 ',' $ progressid '));
$ Ipid = mysql_insert_id();

$ result = mysql_query($ query)或die(mysql_error());
}
if(!empty($ result)){

$ useremail = $ _ SESSION [' 电子邮件'];
require ' PHPMailer_5.2.4 / PHPMailer_5.2.4 / class.phpmailer.php';
$ mail = new PHPMailer;

$ mail-> IsSMTP(); // 将邮件程序设置为使用SMTP
$ mail-> Host = ' smtp.office365.com'; // 指定主服务器和备用服务器
$ mail-> Mailer = smtp;
$ mail-> SMTPAuth = false;
$ mail-> IsHTML(true); // 将电子邮件格式设置为HTML
$ mail-> ContentType = text / html;

$ mail-> From = ' $ useremail';
$ mail-> FromName = $ _ SESSION [' 用户名'];
$ mail-> AddAddress($ row [' Email']); // 名称是可选的

$ mail-> Subject = ' IPDS系统通知';
$ mail-> Body = ' 请执行改进计划'< /跨度>;

if(!$ mail-> Send()){
echo ' 无法发送消息。';
echo ' 邮件程序错误:'。 $ MAIL-> ERRORINFO;
退出;
} else {
echo ' 已发送消息';
}
?>
< 表单 名称 = ipdprogress 方法 = 发布 action = <?php echo $ _SERVER ['PHP_SELF'] ; ??> >
< 输入 type = hidden 名称 = Progressid value = <?php echo $ progressid; ??> / >
< table width = 850 border = 1 >
< tr align = center >
< th width = 80 范围 = col > 负责任< / th < span class =code-keyword>>

< 输入 type = submit name = Notify2 value = 通知 / >
< / tr >
< ; / form >
<? php < br mode = hold /? >
$ disable ='';
$ i = 0;
$ d = 0;

$ con = mysql_connect(localhost,user,);
if(!$ con)
{
die('无法连接:'。mysql_error());
}
mysql_select_db(pq,$ con);
$ sql =SELECT * FROM improvement_plan where Ipid ='。 $ Ipid。 ';
$ res_list = mysql_query($ sql);
if(isset($ _SESSION ['Progressid'])){
$ progressid = $ _SESSION ['Progressid'];
// mysql_query(INSERT INTO improvement_plan(Responsible2 VALUES('。$ _SESSION [Position]。'));
// $ message =记录修改成功;
}
while($ row_list = mysql_fetch_array($ res_list)){
$ i ++;
?>
< tr > < td align = center > < div id = Responsible2<?php echo $ i;?> > <? php i f($ row_list [' Responsible2']!= ' 0000-00-00'){ echo ($ row_list [' Responsible2']); } else { echo ' - '; }??> < / div > < / td < span class =code-keyword>>
< / tr >
< tr > < td align = center > < div id = Progressid<?php echo $ i; ?>
> <? php if($ row_list [' Progressid']!= ' 0000-00-00' ){ echo ($ row_list ['' Progressid']);} else { echo ' - ;}??> < / div > < / td > < / tr >

}
if($ i == 0){
?>
< tr > < td colspan = 7 > 否数据。< / td > < / tr >
$ disable ='disabled =disabled';
}
?>
if($ row ['Status2'] =='buka'){}
?>
< br >
< / br > < / table >
< / form >

解决方案

con = mysql_connect( localhost user,< span class =code-string> );
if (!


con){
die( 无法连接: .mysql_error());
}
mysql_select_db( pq


CON);


Hi everyone, am trying to save records into improvement_plan table and then send email to the responsible person. Upon selection of Responsible2 from combobox, the program suppose to save the Responsible2 into improvement_plan table and then send email notification to that person. However, i was not able to save and send the email. Please advise. Thanks a lot.

error_reporting(E_ALL ^ E_NOTICE);
$con = mysql_connect("localhost","user","");
if (!$con){
die("Can not connect: " . mysql_error());
}
mysql_select_db("pq",$con);
$sql = "SELECT * FROM user";
$rs = mysql_query($sql) or die(mysql_error());
echo "<select name='responsible2'>";
while($row = mysql_fetch_array($rs)){
echo "<option value=".$row['Email'].">".$row['Position']."</option>";

$responsible2=$row['Position'];
echo $responsible2;
}
mysql_free_result($rs);
"</select>"; 
 
if(isset($_POST['Notify2'])){

$responsible2=$_POST['responsible2'];
$progressid=$_SESSION['Progressid'];
echo $progressid;	
	
mysql_query("INSERT INTO improvement_plan (Responsible2,Progressid) VALUES ('" . $responsible2 . "','" . $progressid . "')"); 
$Ipid = mysql_insert_id();

 $result = mysql_query($query) OR die(mysql_error()); 
}
if(!empty($result)) {	

$useremail=$_SESSION['Email'];
require 'PHPMailer_5.2.4/PHPMailer_5.2.4/class.phpmailer.php';
$mail = new PHPMailer;

$mail->IsSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.office365.com';   // Specify main and backup server
$mail->Mailer   = "smtp";
$mail->SMTPAuth = false; 
$mail->IsHTML(true);                                  // Set email format to HTML
$mail->ContentType = "text/html";
                              
$mail->From ='$useremail';  
$mail->FromName =$_SESSION['Username'];	
$mail->AddAddress($row['Email']);               // Name is optional

$mail->Subject = 'IPDS system Notification';
$mail->Body    = 'Please do your Improvement Plan';

if(!$mail->Send()) {
   echo 'Message could not be sent.';
   echo 'Mailer Error: ' . $mail->ErrorInfo;
   exit;
}else{
	echo 'Message has been sent'; 
} 
?>
<form name="ipdprogress" method="post" action="<?php echo $_SERVER['PHP_SELF']; ??>">
    <input type="hidden" name="Progressid" value="<?php echo $progressid; ??>" />
    <table width="850" border="1">
      <tr align="center">
      	<th width="80" scope="col">Responsible</th>
        <input type="submit" name="Notify2" value="Notify" /> 
	 </tr> 
	 </form>
<?php <br mode="hold" /?>
    $disable = '';
    $i = 0;
    $d = 0;

$con = mysql_connect("localhost","user","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("pq", $con);	
$sql = "SELECT * FROM improvement_plan where  Ipid='" . $Ipid . "'";
$res_list = mysql_query($sql);
if( isset( $_SESSION['Progressid'] ) ) {
 $progressid= $_SESSION['Progressid'];
//mysql_query("INSERT INTO improvement_plan (Responsible2 VALUES ('" . $_SESSION["Position"] . "')"); 
//$message = "Record Modified Successfully";  
  }
while($row_list = mysql_fetch_array($res_list)){
    $i++;		
?>  
 <tr><td align="center"><div id="Responsible2<?php echo $i; ?>"><?php if($row_list['Responsible2'] != '0000-00-00'){ echo ($row_list['Responsible2']); }else{ echo '-'; } ??></div></td></tr>
 <tr><td align="center"><div id="Progressid<?php echo $i; ?>"><?php if($row_list['Progressid'] != '0000-00-00'){ echo ($row_list['Progressid']); }else{ echo '-'; } ??></div></td></tr>
  
} 
if($i == 0){
?>
<tr><td colspan="7">No data.</td></tr> 
    $disable = 'disabled="disabled"';
}
?>
if($row['Status2'] == 'buka'){ }
?> 
<br>
</br></table>
</form>

解决方案

con = mysql_connect("localhost","user",""); if (!


con){ die("Can not connect: " . mysql_error()); } mysql_select_db("pq",


con);


这篇关于保存记录并通过php中的电子邮件通知负责人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆