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/7/user-interface/2.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
创建一个人们可以在下面添加想法的页面(HTML/PHP)_Php_Html_Forms - Fatal编程技术网

创建一个人们可以在下面添加想法的页面(HTML/PHP)

创建一个人们可以在下面添加想法的页面(HTML/PHP),php,html,forms,Php,Html,Forms,基本上,我想在我的网站上添加一个系统,人们可以通过表单提交想法。现在我最初是这样做的: <form name="web_form" id="web_form" method="post" action="process-form-data.php"> <p><label>Name: </label><input type="text" name="name" id="name" /></p>

基本上,我想在我的网站上添加一个系统,人们可以通过表单提交想法。现在我最初是这样做的:

<form name="web_form" id="web_form" method="post" action="process-form-data.php">
        <p><label>Name: </label><input type="text" name="name" id="name" /></p>
        <p><label>Idea: </label><input type="text" name="idea" id="idea" maxlength="3000" height="400px" width="550px" /></p>
        <p><input type="submit" name="s1″ id="s1″ value="Submit" /></p>
</form>

姓名:

想法:

处理表单数据,然后将信息发送到文本文件:

<?php
$name = $_POST['name'];
$idea = $_POST['idea'];
$fp = fopen("ideas.txt", "a");
$savestring = $name . "," . $idea . "n";
fwrite($fp, $savestring);
fclose($fp);
echo "<h1>You data has been saved in a text file!</h1>";
?>

但是,当在原始页面中包含.txt文件时,它将以如下所示的单行格式显示:

名字,想法萨姆,这是我的想法萨姆,这是我的想法萨姆,这是我的想法萨姆

对于不懂网络的用户来说,实现这个系统的更好方法是什么

我想要的只是一个简单的页面,所有登录的人都可以看到所有想法

非常感谢

$savestring = $name . "," . $idea . "\n";
您错过了一个
\n


使用具有良好配置的体面IDE可以突出显示带有转义的特殊字符。这有助于找出此类简单错误。

如果要在浏览器中显示文本文件的内容,它需要与HTML兼容。因此,对于每条换行符,您需要

$savestring = $name . "," . $idea . "<br>";
$savestring=$name。"," . $主意“
”;
最好的方法是使用数据库。如何在简单的.php页面中包含数据库?