Skip to content

Instantly share code, notes, and snippets.

@petk
Created December 28, 2014 13:18
Show Gist options
  • Save petk/047fec14bb504a3ef598 to your computer and use it in GitHub Desktop.
Save petk/047fec14bb504a3ef598 to your computer and use it in GitHub Desktop.
File navigation
<?php
$tire = $_POST['tire'];
$oil = $_POST['oil'];
$spark = $_POST['spark'];
$shipping = $_POST['shipping'];
$totalquantity = $tire+$oil+$spark+$shipping;
$totalamount = $totalquantity * 10;
$outputstring = date('H:i, jS F Y')."\t".$tire."tires \t".$oil."oil \t".$spark."spark \t".$totalamount."\t".$shipping."\n";
@ $fp = fopen("C:\\wamp\\www\\PracticePHP\\vieworders\\orders.csv", 'ab');
flock($fp, LOCK_EX);
if(!$fp){
echo "<p><strong>Your order could not be processed at this time. Please try again later.</p></strong>";
exit;
}
fwrite($fp, $outputstring);
flock($fp, LOCK_UN);
fclose($fp);
echo "Final position of the file is".(ftell($fp));
echo "<br /><br />";
rewind($fp);
echo "Tell final position after rewind".(ftell($fp));
echo "<br /><br />";
echo "<h1>Bob's order results</h1>";
echo "<br /><br />";
echo "<h3>Order Results</h3>";
echo "<br /><br />";
echo "<p>Order processed at";
echo date('H:i, jS F Y');
echo "</p>";
echo "<br /><br />";
echo "Your Order is as follows:";
echo "<br /><br />";
echo "Items ordered".$totalquantity;
echo "<br />";
echo $tire."tires";
echo "<br />";
echo $oil."bottlesofoil";
echo "<br />";
echo $spark."sparkplugs";
echo "<br />";
echo "The total amount of order is:".$totalamount."$";
echo "<br />";
echo "The shipping address is:".$shipping;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment