bassey inyang's Profile
Reputation: 0 Apprentice
- New Members
- Active Posts:
- 8 (0.01 per day)
- 07-July 11
- Profile Views:
- Last Active:
- Aug 07 2011 12:19 PM
- Dream Kudos:
Posts I've Made
Posted 7 Aug 2011Thanks every one for responding especially Rudi I am moving ahead to learn arrays and a whole bunch of other php stuffs.
looking forward to learning mysql.
Posted 6 Aug 2011tried did'nt work out:
<?php // create short variable names $tireqty = $_POST['tireqty']; $oilqty = $_POST['oilqty']; $sparkqty = $_POST['sparkqty']; $address = $_POST['address']; $filepath = $_SERVER['DOCUMENT_ROOT']; ?> <html> <head> <title>Bob's Auto Parts - Order Results</title> </head> <body> <h1>Bob's Auto Parts</h1> <h2>Order Results</h2> <?php echo "<p>Order processed at ".date('H:i, jS F Y')."</p>"; echo '<p>Your order is as follows: </p>'; $totalqty = 0; $totalqty = $tireqty + $oilqty + $sparkqty; echo "Items ordered: ".$totalqty."<br />"; $totalamount= 0.00; define('TIREPRICE', 100); define('OILPRICE', 10); define('SPARKPRICE', 4); $totalamount = $tireqty * TIREPRICE + $oilqty * OILPRICE + $sparkqty * SPARKPRICE; echo "Subtotal: $".number_format($totalamount,2)."<br />"; $taxrate = 0.10; // local sales tax is 10% $totalamount = $totalamount * (1 + $taxrate); echo "Total including tax: $".number_format($totalamount,2)."<br />"; echo "<p>Total of order is $".$totalamount."</p>"; echo "<p>Address to ship to is ".$address."</p>"; $filePath = realpath(DOCUMENT_ROOT . '/../order/order.txt'); echo $filePath; $fp = fopen($filePath, 'c'); ?> </body> </html>
I set the security to allow for files to be written and read created order/order.text uploaded to wamp server,
still generated the error:Use of undefined constant DOCUMENT_ROOT - assumed 'DOCUMENT_ROOT' in C:\wamp\www\processorder.php on line 40.
Posted 6 Aug 2011sorry about that everyone, it is actually supposed to be:
$order = $_POST['order']; $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT']; <?php // open file for appending $fp = fopen("$DOCUMENT_ROOT/../order/order.txt", 'w'); ?>
I use a WAMP and had uploaded order. txt. I want the user to be able to write his address in the form and the input to be stored in a text file.
but if i run the code on a broswer it generates:( ! ) Warning: fopen(C:/wamp/www//../orders/orders.txt) [function.fopen]: failed to open stream: No such file or directory in C:\wamp\www\processorder.php on line. I am using a wamp (just learning the language.)
I guess i don't have permission to to write or read a file how do i solve the problem run a windows with wamp server.
My problem is just to know who to create a order.txt test it to know it is working so I can write to it and read from it.
guess must have been stressed up when i wrote the first post.
Posted 31 Jul 2011Thank you all for reading my post and putting me through, I did it the other way round but when I typed into the browser I got the expected response but I still do have a question.
Thus this mean that if i write a code that needs testing I have to save it in the www directory before running the test?
I am quite new to all these so pardon me if i am asking all the wrong questions.
I love you guys for free,
biting myself for not knowing you guys a long time ago
- Member Title:
- New D.I.C Head
- Age Unknown
- Birthday Unknown
- Click here to e-mail me