<?php
if(session_status() == PHP_SESSION_NONE)
{
  session_start();
}
require_once('mysqli_con.php');

if(isset($_SESSION['byrID']))
{
  if(isset($_POST['report']))
  {
    echo "Buyer : " .$_SESSION['byrID']. " reported Seller : " . $_SESSION['sellerID'] . " | Report Type :" . $_POST['report'];
  }

  $sqlReport = "INSERT INTO report ( status_report, buyer_id, seller_id)
  VALUES ('".$_POST['report']."',".$_SESSION['byrID'].",".$_SESSION['sellerID'].")";

  if (mysqli_query($conn, $sqlReport)){
    echo "<br/>Thank you. You will be redirected in 10 seconds.";
    echo '<meta http-equiv="refresh" content="10;URL=userP2.php?sellerid='.$_SESSION['sellerID'].'" />';
  }
  else
  {
    echo mysqli_errno($conn) . "::" . mysqli_error($conn);

    echo '<meta http-equiv="refresh" content="1;URL=userP2.php?sellerid='.$_SESSION['sellerID'].'" />';
  } 
}
else
{
  echo "<script type='text/javascript'>
        alert('Please login to report seller!');
        window.location.replace('http://localhost/fyp_draft/login.php');
			</script>";
}
?>
