-1

I have this page where the administrator approves/rejects employee leaves.

Leave Details

I'm trying to make approve/reject show up under status when I click on it. I followed the exact same code on the tutorial, apparently I do have a syntax error. The error was "Parse error: syntax error, unexpected '}'"

Here's my code:

 <body>
  
<?php 
if(isset($_POST['approved']))
{
  echo "approved";
  $status=$_POST['status']
}
if(isset($_POST['rejected']))
{
  echo "rejected";
  $status=$_POST['status']
}
?>
 
    <!-- Begin page content -->
    <div class="container">
      <div class="page-header">

<h3>
 Employee Leaves
</h3>
   <div class="table-responsive">
    <table class="table">
     <tr>
      <th>Employee Name</th>
      <th>Phone</th>
      <th>Email</th>
      <th>From</th>
      <th>To</th>
      <th>Reason</th>
      <th>Status</th>
      <th>---</th>
     </tr>
    <?php
     include ('database.php');
     $result = $database->prepare ("SELECT * FROM leaves order by id DESC");
     $result ->execute();
     for ($count=0; $row_message = $result ->fetch(); $count++){
    ?>
     <tr>
      <td><?php echo $row_message['full_name']; ?></td>
      <td><?php echo $row_message['phone']; ?></td>
      <td><?php echo $row_message['email']; ?></td>
      <td><?php echo $row_message['fromdate']; ?></td>
      <td><?php echo $row_message['todate']; ?></td>
      <td><?php echo $row_message['reason']; ?></td>
      <td><?php echo $row_message['status']; ?></td>
      <td>
      <form method="post" action=""><button type="submit" name="approved">Approve</button></form>
      &nbsp
      <form method="post" action=""><button typ="submit" name="rejected">Reject</button></form>
      </td>
     </tr>
     <?php } ?>
    </table>
    
    <a href="home"><button type="button" class="btn btn-primary"><i class="glyphicon glyphicon-arrow-left"></i> Back</button></a>
    
   </div>
  </div>
Ravi
  • 30,829
  • 42
  • 119
  • 173
John Z
  • 3
  • 1

1 Answers1

0

In php you always have to close off your lines with a ;. You forgot to add 2 ;.

 if(isset($_POST['approved']))
 {
  echo "approved";
  $status=$_POST['status'];
}
if(isset($_POST['rejected']))
{
echo "rejected";
$status=$_POST['status'];
}
Jonny
  • 1,319
  • 1
  • 14
  • 26