Hi everyone, I wanted to display different data from the same table in 2 different tabs in php. When i select the Responsible person and click Notify in tabs-1, it will be saved and displayed in the improvement_plan table. But when i select Responsible person and click Notify in tabs-2, Responsible person is not save and not display in the improvement_plan table. Please advise how to solve this matter. Thanks a lot.
<form action="progress.php" method="post" form name="progress" id="progress">
<input type="hidden" name="Progressid" id="Progressid" value="">
3.Improvement Plan
Team Leader:<input type="text" readonly="readonly" name="Position" id="Position" value="" >
Session_start();
$cn=mysql_connect("localhost","user","") or die(mysql_error());
mysql_select_db("pq",$cn) or die(mysql_error());
$_SESSION['Progressid']=$row['Progressid'];
if(isset($_POST['Notify2'])){
$responsible = filter_input(INPUT_POST, 'responsible2', FILTER_SANITIZE_STRING);
$q = "SELECT Email FROM user WHERE Position = '".$responsible."'";
$r = mysql_query($q) or die(mysql_error());
while($row = mysql_fetch_array($r))
{
"Email:".$row['Email']."
";
$cemail2=$row['Email'];
}
echo $cemail2;
echo $_SESSION['Progressid'];
$responsible2=$_POST['responsible2'];
echo $responsible2;
echo $_SESSION['Email'];
echo $_SESSION['Username'];
mysql_query("INSERT INTO improvement_plan (Responsible2,Progressid) VALUES ('" . $responsible2 . "', '" . $_SESSION['Progressid'] . "')");
$Ipid = mysql_insert_id();
# send the email
if( ! empty($Ipid))
{
$message = "New improvement plan added successfully";
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 =($_SESSION['Email']);
$mail->FromName =($_SESSION['Username']);
$mail->AddAddress("$cemail2"); // Name is optional
$mail->Subject = 'system Notification';
$mail->Body = 'IP system ';
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}else{
echo 'Message has been sent';
}
}
}
$responsibles = mysql_query("SELECT * FROM user");
?>
<input type="hidden" name="Progressid" value="" />
<select name="responsible2" id="responsible2">
while($row = mysql_fetch_array($responsibles))
echo "<option value=\"{$row['Position']}\">{$row['Position']}</option>";
?>
</select>
<input type="submit" name="Notify2" value="Notify"/>
$disable = '';
$i = 0;
$d = 0;
$con = mysql_connect("localhost","user","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("pq", $con);
$Progressid= $_SESSION['Progressid'];
$sql = "SELECT * FROM improvement_plan where Progressid ='" . $Progressid . "'";
$res_list = mysql_query($sql);
while($row_list = mysql_fetch_array($res_list)){
$i++;
?>
}
if($i == 0){
?>
$disable = 'disabled="disabled"';
}
?>
Ipid | Item | Responsible |
|
|
|
|
|
|
No data. |
mysql_close($con);
?>
<input type="hidden" name="Progressid" id="Progressid" value="">
3.Improvement Plan
Team Leader:<input type="text" readonly="readonly" name="Position" id="Position" value="" >
Session_start();
$cn=mysql_connect("localhost","user","") or die(mysql_error());
mysql_select_db("pq",$cn) or die(mysql_error());
echo $_SESSION['Progressid'];
if(isset($_POST['Notify4'])){
$responsible1 = filter_input(INPUT_POST, 'responsible4', FILTER_SANITIZE_STRING);
$q = "SELECT Email FROM user WHERE Position = '".$responsible1."'";
$r = mysql_query($q) or die(mysql_error());
while($row = mysql_fetch_array($r))
{
"Email:".$row['Email']."
";
$cemail4=$row['Email'];
}
echo $cemail4;
echo $_SESSION['Progressid'];
$responsible4=$_POST['responsible4'];
echo $responsible4;
echo $_SESSION['Email'];
echo $_SESSION['Username'];
$sql=("Update improvement_plan set Responsible4='" . $responsible4 . "' WHERE Progressid='" . $_SESSION['Progressid'] . "'");
{
$result = mysql_query("SELECT * FROM improvement_plan WHERE Progressid='" . $_SESSION['Progressid'] . "'");
$row= mysql_fetch_array($result);
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 =($_SESSION['Email']);
$mail->FromName =($_SESSION['Username']);
$mail->AddAddress("$cemail4"); // Name is optional
$mail->Subject = 'system Notification';
$mail->Body = 'IP system';
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}else{
echo 'Message has been sent';
}
}
}
$responsibless = mysql_query("SELECT * FROM user");
?>
<input type="hidden" name="Progressid" value="" />
<select name="responsible4" id="responsible4">
while($row = mysql_fetch_array($responsibless))
echo "<option value=\"{$row['Position']}\">{$row['Position']}</option>";
?>
</select>
<input type="submit" name="Notify4" value="Notify"/>
$disable = '';
$i = 0;
$d = 0;
$con = mysql_connect("localhost","user","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("pq", $con);
$Progressid= $_SESSION['Progressid'];
$sql = "SELECT * FROM improvement_plan where Progressid='" . $Progressid . "'";
$res_list = mysql_query($sql);
while($row_list = mysql_fetch_array($res_list)){
$i++;
?>
}
if($i == 0){
?>
$disable = 'disabled="disabled"';
}
?>
Ipid | Item | Responsible |
|
|
|
|
|
|
No data. |
mysql_close($con);
?>
<input type="submit" name="submit" id="submit" value="Save" class="btnSubmit"> |
</form>