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">
<div id="tabs-1">
<input type="hidden" name="Progressid" id="Progressid" value="<?php echo $row['Progressid']; ?>">
<p><b>3.Improvement Plan</b></p>
<p>Team Leader:<input type="text" readonly="readonly" name="Position" id="Position" value="<?php echo $_SESSION["Position"];?>" ></p>
<?php
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']."<br/>";
$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="<?php echo $row['Progressid']; ?>" />
<table width="850" border="1">
<tr align="center">
<th width="70" scope="col">Ipid</th>
<th width="70" scope="col">Item</th>
<th width="80" scope="col">Responsible</th>
<select name="responsible2" id="responsible2">
<?php
while($row = mysql_fetch_array($responsibles))
echo "<option value=\"{$row['Position']}\">{$row['Position']}</option>";
?>
</select>
<input type="submit" name="Notify2" value="Notify"/>
</tr>
<?php
$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++;
?>
<td align="center"><div name="Ipid" id="Ipid<?php echo $i; ?>"><?php if($row_list['Ipid'] != '0000-00-00'){ echo ($row_list['Ipid']); }else{ echo '-'; } ?></div></td>
<td align="center"><div name="Item2" id="Item2<?php echo $i; ?>"><?php if($row_list['Item2'] != '0000-00-00'){ echo ($row_list['Item2']); }else{ echo "-"; } ?></div></td>
<td align="center"><div name="Responsible2" id="Responsible2<?php echo $i; ?>"><?php if($row_list['Responsible2']!= '0000-00-00'){ echo ($row_list['Responsible2']); }else{ echo '-'; } ?></div></td>
<td align="center"><div name="Progressid" id="Progressid<?php echo $i; ?>"><?php if($row_list['Progressid'] != '0000-00-00'){ echo ($row_list['Progressid']); }else{ echo '-'; } ?></div></td>
</tr>
<?php
}
if($i == 0){
?>
<tr><td colspan="7">No data.</td></tr>
<?php
$disable = 'disabled="disabled"';
}
?>
<br>
</table>
<br>
<?php
mysql_close($con);
?>
</div>
<div id="tabs-2">
<input type="hidden" name="Progressid" id="Progressid" value="<?php echo $row['Progressid']; ?>">
<p><b>3.Improvement Plan</b></p>
<p>Team Leader:<input type="text" readonly="readonly" name="Position" id="Position" value="<?php echo $_SESSION["Position"];?>" ></p>
<?php
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']."<br/>";
$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="<?php echo $row['Progressid']; ?>" />
<table width="850" border="1">
<tr align="center">
<th width="70" scope="col">Ipid</th>
<th width="70" scope="col">Item</th>
<th width="80" scope="col">Responsible</th>
<select name="responsible4" id="responsible4">
<?php
while($row = mysql_fetch_array($responsibless))
echo "<option value=\"{$row['Position']}\">{$row['Position']}</option>";
?>
</select>
<input type="submit" name="Notify4" value="Notify"/>
</tr>
<?php
$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++;
?>
<td align="center"><div name="Ipid" id="Ipid<?php echo $i; ?>"><?php if($row_list['Ipid'] != '0000-00-00'){ echo ($row_list['Ipid']); }else{ echo '-'; } ?></div></td>
<td align="center"><div name="Item4" id="Item4<?php echo $i; ?>"><?php if($row_list['Item4'] != '0000-00-00'){ echo ($row_list['Item4']); }else{ echo "-"; } ?></div></td>
<td align="center"><div name="Responsible4" id="Responsible4<?php echo $i; ?>"><?php if($row_list['Responsible4']!= '0000-00-00'){ echo ($row_list['Responsible4']); }else{ echo '-'; } ?></div></td>
<td align="center"><div name="Progressid" id="Progressid<?php echo $i; ?>"><?php if($row_list['Progressid'] != '0000-00-00'){ echo ($row_list['Progressid']); }else{ echo '-'; } ?></div></td>
</tr>
<?php
}
if($i == 0){
?>
<tr><td colspan="7">No data.</td></tr>
<?php
$disable = 'disabled="disabled"';
}
?>
<br>
</table>
<br>
<?php
mysql_close($con);
?>
</div>
<td colspan="2"><input type="submit" name="submit" id="submit" value="Save" class="btnSubmit"></td>
</form>