<?php 
session_start();
//mysql_connect("localhost","root","vertrigo") or die("Error Connecting Server");
//mysql_select_db("sm") or die("Error Opening Database");
include 'dbc.php';
$username=$_SESSION["username"];
$current_file_name = basename($_SERVER['PHP_SELF']);
$sql = "SELECT * FROM adduser where feedisc2 = '$current_file_name' and uname = '$username'";
$result=$conn->query($sql);
$row = $result->fetch_assoc();
$status=$row['feedisc3'] ;

if ($status =="")
{
echo "You are not Authorized This Page <a href='maindashboard.php'>Back </a> ";
}
else
{



$userid=$_SESSION["userid"];
$id=$_REQUEST["id"];
$sqlpur = "SELECT * FROM cashrec where id = '$id' and user_id = '$userid'";
$resultpur=$conn->query($sqlpur);
$rowpur = $resultpur->fetch_assoc();
$disc=$rowpur['disc'] ;
 
$sql2 = "UPDATE invoice_st SET status='Pending' WHERE id='$disc'";
$conn->query($sql2);
	  

$sql = "delete from cashrec where id='$id' and user_id='$userid'";
$conn->query($sql);

$Message = "Record Deleted";
    header("Location:Open_Receipt.php");

/*$sql="Select * from agents where userid='$user_id'";
$data=mysql_query($sql) or die ("Error:" . mysql_error());
$userdata=mysql_fetch_array($data);
$email=$userdata["e_mail"];
mail($email . ",info@lalburj.com","Candidate Information","Candidate Data Posted Successfully","Passport No:" . $app_pp_no . " of " . $app_name . "Has been Posted Successfully By:" . $_SESSION["userid"]);*/
}
?>
