【问题标题】:Does recording to a text document in php work the same for linux as it does in windows在 php 中记录到文本文档对 linux 的工作方式与在 Windows 中的工作方式相同吗
【发布时间】:2020-03-24 06:19:36
【问题描述】:

我最近一直在研究如何使用 php,并且发现如何通过标准 .txt 文件上的表单记录输入,但是当将其从我的 Windows 计算机(运行 wamp 服务器)传输到 Linux(运行 Kali Linux)文本文件是空白的,我假设这意味着没有任何记录。是的,我在 Linux 系统上运行了 apache,但是在 localhost 上它不像在我的 Windows 上那样工作。我的猜测是,这可能与 Linux 和 Windows 与文本文件的交互方式不同这一事实有关,但我不确定。感谢您提供以下练习网站的帮助代码。

    <!DOCTYPE html>
<html>
    <head>

        <style>
            @font-fact{
                font-family: Penguin; src: url("Penguin Sans 0.500.ttf");
            }
            body{

                font-family: Penguin, monospace;

                }
            html{
                height: 100%;
                margin:0px;
                background: url("background.png") no-repeat center center;
                background-size: cover;
                background-attachment: fixed;
            }
            .headimage{
                margin-left: -3%;
                margin-top: .5%;
            }
            .survey{
                margin-top: 5%;
                padding-bottom: 5%;

            }
            a{
                text-decoration: none;
                color: white;
            }
            .button {
                background-color: green;
                border: none;
                color: purple;
                padding: 5px;
                text-align: center;
                text-decoration: none;
                display: inline-block;
                font-size: 16px;
                margin: 4px 2px;
                cursor: pointer;
            }
            .buttonpay{
                border-radius: 12px;
            }

            .buttonpay:hover{
                color: green;
                background-color: purple;
            }
            .buycodebox{
                background-color: white;
                color: red;
                border: none;
                padding: 10px;
                text-align: center;
                text-decoration: none;
                display: inline-block;
                font-size: 20px;
                margin: 10px;
                font-family: monospace;
            }
            .too{
                border-width: 1px;
                background-color: #afd99c; 
                border-radius: 4px;
                border-color: purple;
              }
              form{
                width: 25%;
              }
              .to{
                background-color: purple;
                color: green;
                border-radius: 4px;
                border-color: purple;
              }
              .to:hover{
                background-color:green;
                color: purple;
                border-color: green;
              }

        </style>
    </head>
    <body>

        <div class = "headimage"><img src="THISISTHEONEgreen.png"  width="15%"></div>
        <!--BUY CODE-->
        <center>
        <div class = "buycodebox">
            CODE = BLUEFADESMALL
        </div>
        <center>
            <form method="post">
            CODE<br>
            <input type="text" name="textdata" class = "too"><br>
            ADDRESS<br>
            <input type="text" name="textdata1" class = "too"><br>
            STATE<br>
            <input type="text" name="textdata2" class = "too"><br>
            CITY<br>
            <input type="text" name="textdata3" class = "too"><br>
            ZIP<br>
            <input type="text" name="textdata4" class = "too"><br>
            <br>
            <input type="submit" name="submit" value="SUBMIT" class ="to">
          </form>
        </center>
        <br>
        ONCE FILLED OUT
        <br>
        <br>
        <center>
            <a href = "#"><button class="button buttonpay">CONTINUE</button></a>
        </center>
        <center>
        <p>
            QUESTIONS?
        </p>
        </center>




    </body>
</html>
<?php

 if(isset($_POST['textdata']))
 if(isset($_POST['textdata1']))
 if(isset($_POST['textdata2']))
 if(isset($_POST['textdata3'])) 
 if(isset($_POST['textdata4']))
 {
 $data=$_POST['textdata'];
 $data1=$_POST['textdata1'];
 $data2=$_POST['textdata2'];
 $data3=$_POST['textdata3'];
 $data4=$_POST['textdata4'];
 $fp = fopen('data.txt', 'a');

 fwrite($fp, $data . ",");
 fwrite($fp, $data1 . ",");
 fwrite($fp, $data2 . ",");
 fwrite($fp, $data3 . ",");
 fwrite($fp, $data4 . "/" );
 fclose($fp);
 }
 ?>

【问题讨论】:

    标签: php html linux windows


    【解决方案1】:

    这似乎是一个权限问题。

    尝试运行这个命令:

    chmod 777 data.txt
    

    【讨论】:

      猜你喜欢
      • 2020-09-29
      • 2011-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-23
      • 2017-10-22
      • 1970-01-01
      相关资源
      最近更新 更多