我有项目要做。 我需要从表单导出文件。 项目abotu摄影网站,有节我们的客户可以通过填写订单表格“购买”订单。 所以我想要做的是保存订单中的输入。
表格
libtango_3d_reconstruction.so
那是我的尝试
<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>
@PatrickQ现在就是我得到的:---
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 was an error writing this file');
}
else {
echo "$ret bytes written to file";
}
}
else {
die('no post data to process');
}
这就是我希望它:
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
答案 0 :(得分:0)
你没有正确地打电话给你的班级。
更改
$db = new Order;
到
$db = new Order();
答案 1 :(得分:0)
无法自动获取您在输入字段旁边使用的文本。你只需要对其进行硬编码。
$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";