Export form in php to text file -
i have project do. need export form file text. project abotu photography web-site,there section our customers can "buy" order filling order form. want save input order form.
form
<h3>order</h3> <form action="shop.php" method="post"> order number: <input type="text" name="onumber"><br><br> product name: <input type="text" name="product_name"><br><br> customer name: <input type="text" name="name"><br><br> customer number: <input type="text" name="cnumber"><br><br> e-mail: <input type="text" name="email"><br><br> phone number: <input type="text" name="phone"><br><br> quantity: <input type="text" name="quantity"><br><br> <input type="submit" name="add_order" value="add order"> </form>
thats try
if(isset($_post['onumber']) && isset($_post['product_name'])&&isset($_post['name'])&&isset($_post['cnumber'])&&isset($_post['email'])&&isset($_post['phone'])&&isset($_post['quantity']) { $data = $_post['onumber'] . '-' . $_post['product_name'] .$_post['name'] . '-' . $_post['cnumber'] . $_post['email'] . '-' . $_post['phone'] . '-' . $_post['quantity'] ."\n"; $ret = file_put_contents('c:\ben\mydata.txt', $data, file_append | lock_ex); if($ret === false) { die('there error writing file'); } else { echo "$ret bytes written file"; } } else { die('no post data process'); }
@patrickq thats got: ---
1234-gallinder-1234lindergal@gmail.com-1239 1234---- 1234-blabla-1234gal_124@walla.co.il-1234-1 gf-gfdgf33-323232-34223-1 gdfgfdorder numberfgdfdsfd-fdsfdfdsfd-fsdfds-1 121212-photolinder-147852lindergal@gmail.com-0544876117-1
and thats want be:
order number :1212 product name:photo customer name:gal e-mail:bla@gmail.com phone number :0544876117 quantity:1 --------------------------------- order number :1213 product name:photo customer name:gal e-mail:bla@gmail.com phone number :0544876117 quantity:1
there's no way automatically text you're using next input fields. have hard-code that.
$data = "order number: " . $_post['onumber'] . "\n"; $data .= "product name: " . $_post['product_name'] . "\n"; $data .= "customer name: " . $_post['name'] . "\n"; $data .= "e-mail: " . $_post['email'] . "\n"; $data .= "phone number: " . $_post['phone'] . "\n"; $data .= "quantity: " . $_post['quantity'] ."\n"; $data .= "---------------------------------\n";
Comments
Post a Comment