everytime I submit I get the message that is programmed near the bottom that is supposed to pop up if there is an error.
The forms information never stores in the .txt file like it is suppose to so I am assuming I have the fopen() folders not installed right
right now I am using wamp server, I have my form orderform.html and processorder.php (this file below) in a folder called webserver. Also in the webserver folder is a folder called orders. Inside the orders folder is my orders.txt file where I am trying to store data
<?php
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
$address = $_POST['address'];
echo '<p>Order processed at ';
echo date('H:i, jS F');
echo '</p>';
echo '<p>Your order is as follows: </p>';
echo $tireqty.' tires<br />';
echo $oilqty.' bottles of oil <br />';
echo $sparkqty.' Spark Plugs <br />';
$totalqty =0;
$totalqty= $tireqty + $oilqty +$sparkqty;
echo 'Items ordered: '.$totalqty.'<br />'; //total number of items ordered
$totalamount = 0.00; //total amount before tax
define('TIREPRICE', 100);
define('OIL', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE;
echo 'Subtotal: $'.number_format($totalamount,3).'<br />';
$taxrate = 0.10; // sales tax 10%
$totalamount = $totalamount * (1 + $taxrate);
echo 'Total including tax: $'.number_format($totalamount,2).'<br />';
echo '<p>Your address is: </p>';
echo $address.' <br />';
$DOCUMENT_ROOT = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
@fp= fopen("$DOCUMENT_ROOT/../orders/orders.txt", "w");
if (!$fp)
{
echo'<p><strong>Your order could not be process at this time. '
.'Please try again later.</strong></p></body></html>';
exit;
}
fwrite($fp, $outputstring);
$outputstring = $date."\t".$tireqty." tires \t" .$oilqty." oil\t"
.$sparkqty." spark plugs\t\$".$total
."\t". $address."\n";
?>

New Topic/Question
Reply




MultiQuote






|