Hi Folks,
I am currently learning php and Mysql a scripting language and DB i just feel
in love with. I am currently having problem in opening file to put data
collected from clients when the purchase from an online shop. The scripts is as
follows.
where i am having problem is this // open file for appending
$fp = fopen($DOCUMENT_ROOT/../orders/orders.txt , 'a');
flock($fp, LOCK_EX);
Please can someone advise me on how i should go about this. Do i need to
creat a file for orders/orders or is i the script that will do it for me
authomatically. I am confused here. I will be glad if someone can help me out. Thanks.
OZ
UK
The scripts is below:
=
?php
//create short variable names
$tireqty = $HTTP_POST_VARS['tireqty'];
$oilqty = $HTTP_POST_VARS['oilqty'];
$sparkqty = $HTTP_POST_VARS['sparkqty'];
$address = $HTTP_POST_VARS['address'];
$DOCUMENT_ROOT = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
?
html
head
titleBob's Auto Parts - Order Results/title
/head
body
h1Bob's Auto Parts/h1
h2Order Results/h2
?php
$totalqty = 0;
$totalqty += $tireqty;
$totalqty += $oilqty;
$totalqty += $sparkqty;
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);
$date = date('H:i, jS F');
echo 'pOrder processed at ';
echo $date;
echo 'br /';
echo 'pYour order is as follows:';
echo 'br /';
if( $totalqty == 0 )
{
echo 'You did not order anything on the previous page!br /';
}
else
{
if ( $tireqty0 )
echo $tireqty.' tiresbr /';
if ( $oilqty0 )
echo $oilqty.' bottles of oilbr /';
if ( $sparkqty0 )
echo $sparkqty.' spark plugsbr /';
}
$total = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty *
SPARKPRICE;
$total=number_format($total, 2, '.', ' ');
echo 'PTotal of order is '.$total.'/p';
echo 'PAddress to ship to is '.$address.'br /';
$outputstring = $date.\t.$tireqty. tires \t.$oilqty. oil\t
.$sparkqty. spark plugs\t\$.$total
.\t. $address.\n;
// open file for appending
$fp = fopen($DOCUMENT_ROOT/../orders/orders.txt , 'a');
flock($fp, LOCK_EX);
if (!$fp)
{
echo 'pstrong Your order could not be processed at this time. '
.'Please try again later./strong/p/body/html';
exit;
}
fwrite($fp, $outputstring);
flock($fp, LOCK_UN);
fclose($fp);
echo 'pOrder written./p';
?
/body
/html