First write the HTML page:
Order PageJason's Shopping list
Then write the server-side script file in PHP processorder.php
<title>Order results</title>Jason's Shopping Cart
Order results
Time of order submission: '. $date. ''; Echo 'Your specific shopping list is:
'; Get the total quantity of goods $total _qty=0; $total _qty= $cloths + $shoes + $glasses; Echo ' Total number of items: '. $total _qty. '
'; if ($total _qty==0) {echo ' You have not purchased any items! '; }else{if ($cloths >0) {echo $cloths. ' Pieces mens
'; } if ($shoes >0) {echo $shoes. ' Pair of shoes
'; } if ($glasses >0) {echo $glasses. ' Pair of glasses
'; }}//Get the total price of merchandise $total _amount=0.00; Const CLOTHS_PRICE=100; Const SHOES_PRICE=300; Const GLASSES_PRICE=28; $total _amount= $cloths *cloths_price+ $shoes *shoes_price+ $glasses *glasses_price; $total _amount=number_format ($total _amount,2, '. ', '); Echo 'Total Merchandise: ¥ '. $total _amount. '
'; Echo 'Delivery address: '. $address. '
'; Set the file output content and format $out _put_string= $date. \ t ". $cloths." piece mens \ t ". $shoes." Two Shoes \ t ". $glasses." Pair of glasses \t\ Total Price: ¥ ". $total _amount." Delivery address: \ t ". $address." \ n "; Open file, (Append mode + binary mode) @ $fp =fopen ("$DOCUMENT _root/l02/files/orders.text", ' ab '); Flock ($FP, LOCK_EX); if (! $fp) {echo]Your order has not been submitted for completion, please try again.
"; Exit }//Writes data to file Fwrite ($fp, $out _put_string,strlen ($out _put_string)); Flock ($FP, lock_un); Close file stream fclose ($FP); echo "Data Save complete
";? >
Finally, the Orders.txt file is generated under the files file,
the contents of the file are (can be appended):
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.