Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php中将javascript函数放入文本文件_Php_Javascript_Html_Post - Fatal编程技术网

在php中将javascript函数放入文本文件

在php中将javascript函数放入文本文件,php,javascript,html,post,Php,Javascript,Html,Post,我想将客户详细信息和订单保存到一个文本文件中,这不是一个真正的在线商店,只是一个任务 客户在结帐页面上输入所有详细信息,然后单击提交,然后使用php将这些数据保存到文本文件中。我有一个javascript函数来保存订单细节。我希望这两件东西保存在同一个文本文件中,这样我就可以确定客户的订单。(我们还没有使用MySQL) 签出页面的代码 以下列出的项目当前位于您的购物车中: <form action="process.php" method ="post">

我想将客户详细信息和订单保存到一个文本文件中,这不是一个真正的在线商店,只是一个任务

客户在结帐页面上输入所有详细信息,然后单击提交,然后使用php将这些数据保存到文本文件中。我有一个javascript函数来保存订单细节。我希望这两件东西保存在同一个文本文件中,这样我就可以确定客户的订单。(我们还没有使用MySQL)

签出页面的代码 以下列出的项目当前位于您的购物车中:

        <form action="process.php" method ="post">
            <script type="text/javascript">
                CheckoutCart();
                getCartString();

            </script>
            <br /><br />
            First Name:     <input type="text" name="first" /><br />
            Last Name:      <input type="text" name="last" /><br />
            Street Address: <input type="text" name="address" /><br />
            Suburb:         <input type="text" name="suburb" /><br />
            State:          <input type="text" name="state" /><br />
            Postcode:       <input type="text" name="postcode" /><br />
            Country:        <input type="text" name="country" /><br />
            Phone Number:   <input type="text" name="phone" /><br />
            Email:          <input type="text" name="email" /><br />


            shop:           <input type="text" name="shop" /><br />
            <br /><br />
            Other form data can go here when you create your prototype cart ...
            <br /><br />

            <input type="submit" name="submitButton" value=" Submit Order " />
        </form>
        <!-- Checkout End --

签出购物车();
getCartString();


名字:
姓氏:
街道地址:
郊区:
状态:
邮政编码:
国家:
电话号码:
电子邮件:
商店:


当您创建原型购物车时,其他表单数据可以转到此处。。。


关于javascript不能做服务器端的事情,你是对的

可以使用常规表单将信息发布到php页面,也可以使用jQuery AJAX函数将其发布到php页面

<?php
if (isset($_POST['submitButton'])) {
file_put_contents('./data.txt', $_POST['shop'] . " " .$_POST['first'] . " " . $_POST['last'] . "\n" . $_POST['address'] . "\n" . $_POST['suburb'] . " " . $_POST['state'] . " " . $_POST['postcode'] . "\n" . $_POST['country'] . "\n" . "\n", FILE_APPEND);
}
?>