Want the same page with after submit form with updated values

Hello,

When a particular time slot ( start date and end date) is selected, the page pshow.php appears. It shows the entries posted by all the teachers for that time period.

On the extreme right side there are two colums called ‘REMARKS’ and ‘NEW REMARKS’. While the column REMARKS shows all the remarks given by various coordinators ad heads to every teacher, the ‘NEW REMARKS’ column contains a textbox with a submit button where the coordinators can type ans submit their respective remarks for a particular teacher. The form leads to ‘submitfeedback.php’ wherein the code for database insertion lies.

Currently I am getting a blank page after form submit. I want that after remarks submission, the same page ‘pshow.php’ appears with the REMARKS column updated with the recent remark. I think the header(location:…thing is not working because pshow.php is a result of selecting a time period (sql query).
So how do I do it?

My code is

pshow.php:

<?php
session_start();
$user_check=$_SESSION['login_user'];
?>
<body> 

<?php
$i='';
$added='';
$alreadyexists='';

mysql_connect("localhost","kam","sbb") or die(mysql_error()); 

 mysql_select_db("kamla") or die(mysql_error()); 
 


$tmp='';
$sql=mysql_query("select * from teacher order by teachername ASC", $connection);
while ( $row = mysql_fetch_assoc($sql) ){

    $first_letter = mb_substr($row['teachername'],0,1);
    if($tmp!=$first_letter){
        $tmp = $first_letter;
        echo '<h3 >'.$tmp.'</h3>';
        //$id=$row['teacherid'];
    }
    echo "<a href='teacherreports.php?id=".$row['teacherid']."'>".$row['teachername']."</a><br />";

} //end while

mysql_data_seek($row, 0);
 
 
 if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if(empty($_POST['startdate']))
{
$i= "* Please enter a startdate";
}
if(empty($_POST['enddate']))
{
$i= "* Please enter an enddate";
}
else
{
$i='';
$startdate=$_POST['startdate'];
$enddate=$_POST['enddate'];


$result=mysql_query("SELECT * FROM teachersdiary, dateslots, teacher WHERE teacher.teacherid=teachersdiary.teacherid AND   dateslots.slotid=teachersdiary.slotid AND dateslots.startdate='$startdate' AND dateslots.enddate='$enddate'");
//$checked=$part['checked'];

echo "Reports of all teachers from ".$startdate." to ".$enddate." :";

function creategroup($result)
{
echo "<table border='1' p class ='style15' align='left'>
<tr>
<th>SERIAL NUMBER</th>
<th>TEACHER</th>
<th>SUBJECT/CLASS TIME</th>
<th>CONTENT/SUBTOPICS AND TEACHING POINTS </th>
<th>TEACHING AIDS/RESOURCES </th>
<th>INSTRUCTIONAL SEQUENCE (TEACHING METHODOLOGY WITH STUDENT ACTIVITIES) </th>
<th>APPLICATION ACTIVITY(PRACTICES AND/OR REFLECTION) </th>
<th>ASSESSMENT STRATEGIES(METHODS FOR OBTAINING EVIDENCE OF LEARNING) </th>
<th>LEARNING OUTCOMES</th>
<th>REMARKS</th>
<th>NEW REMARKS</th>

</tr>";
$num=1;
  while($group = mysql_fetch_array($result))
  {
  echo "<td valign='top'>" . $num. "</td>";
  echo "<td valign='top'>" . $group['teachername'] . "</td>";
  echo "<td valign='top'>" . $group['subject'] . "</td>";
  echo "<td valign='top'>" . $group['content'] . "</td>";
  echo "<td valign='top'>" . $group['teachingaids'] . "</td>";
  echo "<td valign='top'>" . $group['instructionalsequence'] . "</td>";
  echo "<td valign='top'>" . $group['applicationactivity'] . "</td>";
  echo "<td valign='top'>" . $group['assessmentstrategies'] . "</td>";
  echo "<td valign='top'>" . $group['learningoutcomes'] . "</td>";
  //echo "<td><input name='Submit' type='submit' class='style2' value='". $label. "'/></td>";
  //if ($group['premarks']=='')
 // {
  
  //}
  //else
 // {
  echo "<td valign='top'><b>Remarks for ".$group['teachername']."</b><hr />" . $group['premarks'] . "<br /></td>";
  echo "<td valign='top'><b>Enter remarks for ".$group['teachername']."</b><form method='post' action='submitfeedback.php'><textarea name='txtremarks' id='txtremarks'></textarea> <input name='Submit' type='submit' class='style2' value='POST' /><input type='hidden' name='id' value=".$group['diaryid']." /></form></td>";
  //}
  

  $num++;
  echo "</tr>";
 }
 echo "</table>";    
  }


 
creategroup($result);

    }
}



?>


  <span class="error"> <?php echo $i;?></span><br /> <br />
 <span class="error"> <?php echo $alreadyexists;?></span><br /> <br />
      <span class="error"> <?php echo $added;?></span><br /> <br />



</body>
<html>

submitfeedback.php

<?php

session_start();

$user_check=$_SESSION['login_user'];

$connection = mysql_connect("localhost","kam","sbb");

$db = mysql_select_db("kamla", $connection);


$ses_sql=mysql_query("select * from manager where username='$user_check'", $connection);

$row = mysql_fetch_assoc($ses_sql);

$login_session =$row['managername'];

$designation=$row['designation'];

$date=date('Y-m-d');

$text=mysql_real_escape_string($_POST['txtremarks']);

$remarks=$text."<br /><b>- ".$login_session." (".$designation." )<br />Date: ".$date."</b><hr />";

$id=$_POST['id'];


$i='';

$added='';

$alreadyexists='';

if(empty($_POST['txtremarks']))

{

$i= "* Please enter remarks";

}

else

{

$i='';

$sql=mysql_query("select * from teachersdiary where diaryid='$id'");

$row = mysql_fetch_assoc($sql);

$comments=$row['premarks'];

$newremarks=$comments.$remarks;

$query="update teachersdiary set premarks='$newremarks', pdate=now() where diaryid='$id'";

mysql_query($query) or die ("ERROR: Remarks could not be added." . mysql_error());



$added=$login_session.",<br />Congratulations! Remarks are successfully posted.<br />";

    }

header("location:pshow.php");



?>

<html>

<head>

</head>

<body>

<a href='welcomeprincipal.php' >Back</a><br /><br />

 <b id="logout"><a href="logout.php">Log Out</a></b><br /><br />



  <span class="error"> <?php echo $i;?></span><br /> <br />

 <span class="error"> <?php echo $alreadyexists;?></span><br /> <br />

      <span class="error"> <?php echo $added;?></span><br /> <br />

      </body>

      </html>

You code uses the following the construct the SQL:

$startdate=$_POST['startdate'];
$enddate=$_POST['enddate'];

However you have lost that POST information when you submitted your new information to submitfeedback.php.

$_GET or $_SESSION are probs your best bet for capturing/retaining that information

That is not an issue. Actually there is a table called dateslots where the fields are slotid,startdate,enddate. The slotid is passed instead.

But the whole section of code that displays the table is surrounded by:

 if ($_SERVER["REQUEST_METHOD"] == "POST")
  {

and when you come back to the page, you haven’t come via a POST, you’ve come via a redirect. Not sure why it doesn’t display the list of teachers that is generated before that, though.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.