<? ob_start(); ?>
<?php
/*
Author: Javed Ur Rehman
Website: https://www.allphptricks.com/
*/
 
require('db.php');
include("auth.php");
$id=$_REQUEST['id'];
$query = "SELECT * from new_record where id='".$id."'"; 
$result = mysqli_query($con, $query) or die ( mysqli_error());
$row = mysqli_fetch_assoc($result);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Update Details</title>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<div class="form">
<p><a href="dashboard.php">Home</a> | <a href="insert.php">Create New Tracking</a> | <a href="logout.php">Logout</a></p>
<h1>Edit Tracking</h1>
<?php
$status = "";
if(isset($_POST['new']) && $_POST['new']==1)
{
$id=$_REQUEST['id'];
$trn_date = date("Y-m-d H:i:s");
$tracknumber =$_REQUEST['tracknumber'];
$receivername = $_REQUEST['receivername'];
$receivernos = $_REQUEST['receivernos'];
$receiveradd = $_REQUEST['receiveradd'];
$sendername = $_REQUEST['sendername'];
$sendernos = $_REQUEST['sendernos'];
$senderadd = $_REQUEST['senderadd'];
$origin = $_REQUEST['origin'];
$destination = $_REQUEST['destination'];
$datesent = $_REQUEST['datesent'];
$deliverydate = $_REQUEST['deliverydate'];
$mode = $_REQUEST['mode'];
$invoice = $_REQUEST['invoice'];
$itemdescript = $_REQUEST['itemdescript'];
$weight = $_REQUEST['weight'];
$report = $_REQUEST['report'];
$content = $_REQUEST['content'];
$location1 = $_REQUEST['location1'];
$goodsstatus = $_REQUEST['goodsstatus'];
$submittedby = $_SESSION["username"];
$update="update new_record set trn_date='".$trn_date."', tracknumber='".$tracknumber."', receivername='".$receivername."', receivernos='".$receivernos."',  receiveradd='".$receiveradd."', sendername='".$sendername."', sendernos='".$sendernos."', senderadd='".$senderadd."', origin='".$origin."',   destination='".$destination."', datesent='".$datesent."', deliverydate='".$deliverydate."', mode='".$mode."',  invoice='".$invoice."',  itemdescript='".$itemdescript."',  weight='".$weight."',  report='".$report."',   content='".$content."',   location1='".$location1."',  goodsstatus='".$goodsstatus."',  submittedby='".$submittedby."' where id='".$id."'";
mysqli_query($con, $update) or die(mysqli_error());
$status = "Tracking Details Edited Successfully. </br></br><a href='view.php'>View Tracking Records Created</a>";
echo '<p style="color:#FF0000;">'.$status.'</p>';
}else {
?>
<div>
<form name="form" method="post" action=""> 
<input type="hidden" name="new" value="1" />
<input name="id" type="hidden" value="<?php echo $row['id'];?>" />
<p><input type="text" name="tracknumber" placeholder="Enter Tracking Number" value="<?php echo $row['tracknumber'];?>" /></p>
<p><input type="text" name="receivername" placeholder="Enter Receiver Name" value="<?php echo $row['receivername'];?>" /></p>
<p><input type="text" name="receivernos" placeholder="Enter Receiver Number" value="<?php echo $row['receivernos'];?>" /></p>
<p><input type="text" name="receiveradd" placeholder="Enter Receiver Address" value="<?php echo $row['receiveradd'];?>" /></p>
<p><input type="text" name="sendername" placeholder="Enter Sender Name" value="<?php echo $row['sendername'];?>" /></p>
<p><input type="text" name="sendernos" placeholder="Enter Sender Number" value="<?php echo $row['sendernos'];?>" /></p>
<p><input type="text" name="senderadd" placeholder="Enter Sender Address" value="<?php echo $row['senderadd'];?>" /></p>
<p><input type="text" name="origin" placeholder="Enter Origin Country" value="<?php echo $row['origin'];?>" /></p>
<p><input type="text" name="destination" placeholder="Enter Destination Country" value="<?php echo $row['destination'];?>" /></p>
<p><input type="text" name="datesent" placeholder="Enter Departure Date" value="<?php echo $row['datesent'];?>" /></p>
<p><input type="text" name="deliverydate" placeholder="Enter Arrival Date" value="<?php echo $row['deliverydate'];?>" /></p>
<p><input type="text" name="mode" placeholder="Enter Transport Mode" value="<?php echo $row['mode'];?>" /></p>
<p><input type="text" name="invoice" placeholder="Enter Shipping Fee" value="<?php echo $row['invoice'];?>" /></p>
<p><input type="text" name="itemdescript" placeholder="Enter Parcel Content" value="<?php echo $row['itemdescript'];?>" /></p>
<p><input type="text" name="weight" placeholder="Enter Parcel Weight" value="<?php echo $row['weight'];?>" /></p>
<p><input type="text" name="report" placeholder="Enter First Report" value="<?php echo $row['report'];?>" /></p>
<p><input type="text" name="content" placeholder="Enter Content of the Parcel/Box" value="<?php echo $row['content'];?>" /></p>
<p><input type="text" name="location1" placeholder="Enter Current Location" value="<?php echo $row['location1'];?>" /></p>
<p><input type="text" name="goodsstatus" placeholder="Enter The Status of Parcel"  value="<?php echo $row['goodsstatus'];?>" /></p>
<p><input name="submit" type="submit" value="Update" /></p>
</form>
<?php } ?>

<br /><br /><br /><br />
</div>
</div>
</body>
</html>
<? ob_flush(); ?>