【问题标题】:Comment form in HTML & PHP not displayHTML 和 PHP 中的评论表单不显示
【发布时间】:2018-06-22 16:22:56
【问题描述】:

我对 html/css 也很熟悉 php,而且我的英语很差.. 所以,我的问题...,我有这个来自here 的编解码器。我有三个文件,第一个是 index.php

<html> 
<head> 
<link rel="stylesheet" href="style.css" type="text/css"> 
</head> 

<body> 
<form action="" method="POST"> 
<label>Name: 
<input type="text" name="Name" class="Input" style="width: 225px" required> 
</label> 
<br><br> 
<label> Comment: <br> 
<textarea name="Comment" class="Input" style="width: 300px" required> </textarea> 
</label> 
<br><br> 
<input type="submit" name="Submit" value="Submit Comment" class="Submit"> 
</form> 
</body> 
</html> 

<?php 

    if($_POST['Submit']){  



        $Name = $_POST['Name']; 
        $Comment = $_POST['Comment']; 


        #Get old comments 
        $old = fopen("comments.txt", "r+"); 
        $old_comments = fread($old, 1024); 


        #Delete everything, write down new and old comments 
        $write = fopen("comments.txt", "w+"); 
        $string = "<b>".$Name."</b><br>".$Comment."<br>\n".$old_comments; 
        fwrite($write, $string); 
        fclose($write); 
        fclose($old); 
    } 

        #Read comments 
        $read = fopen("comments.txt", "r+"); 
        echo "<br><br>Comments<hr>".fread($read, 1024); 
        fclose($read); 


?>

比一个 style.css 文件和一个名为 cmets.txt 的空文件。这个文件我必须到一台计算机(computer A),用 apache 启动它,/etc/init.d/apache2 restart。在另一台计算机(计算机 B)我写信给浏览器,192.345.345.100/index.php,在 Name 我写我的名字并在 Comment ,评论..,什么都没有......。图片来自我的浏览器enter image description here,请任何人帮助我,谢谢!

来自计算机 B 的图像,在浏览器中写入 http://192.345.345.100/info.php ,我必须使用 &lt;?php phpinfo(); ?&gt; 构建的 info.php。

查看堆栈跟踪:

【问题讨论】:

标签: php html linux


【解决方案1】:

编辑我的新评论...,我有两个问题,因为 PHP 不显示...。 首先,我弄乱了一些PHP模块,libapache2-mod-php7.0..

,我无权访问我的网站...,使用 sudo chown -R www-data:www-data /var/www/html ,我有这个权利给予...... image how the Website see with the Comments,代码保持不变...

@user3783243,今天我转红this,怎么理解,t将\n转为\r\n,ONLY适用于Windows用户.., Linux 忽略了它... .

\n 用于 Unix 系统(包括 Linux 和 OSX)。

\r\n主要用于Windows。

\r 用于非常旧的 Mac。

来自Here

【讨论】:

  • 所以你“找到”了解决方案,“必须找到”意味着它还没有解决
猜你喜欢
  • 2014-09-08
  • 2014-03-29
  • 2013-06-05
  • 1970-01-01
  • 2014-09-09
  • 1970-01-01
  • 2019-11-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多