【发布时间】:2015-09-22 08:02:04
【问题描述】:
首先这不是我的代码,我只是需要稍微改动一下。
我需要知道如何将消息写入用户发布消息的同一文件中。
这是用户可以发布消息的页面:
<html>
<head>
<title>Form to Flat File</title>
</head>
<body>
<form action="sendinfo.php" method="get">
Your Name:<br />
<input type="text" name="name"><br />
Your Message:<br />
<textarea name="message"></textarea><br />
<input type="submit" value="Send Info">
</form>
</body>
</html>
这是另一个将消息写入 PHP 文件的方法:
<html>
<head>
<title>Form to Flat File</title>
</head>
<body>
<?php
include('config.php');
$user = $_GET["name"];
$message = $_GET["message"];
print("<b>Thank You!</b><br />Your information has been added! You can see it by <a href=savedinfo.php>Clicking Here</a>");
$out = fopen("savedinfo.php", "a");
if (!$out) {
print("Could not append to file");
exit;
}
fputs ($out,implode,("\n"));
fwrite($out,"<b>$user</b><br />$message<br /><br />");
fclose($out);
?>
</body>
</html>
几乎我只想将所有内容都放在一页上,我已经接近做到这一点,但它不会让我在同一页上写字。我敢肯定,我可能还远远不够有经验。请帮忙!
【问题讨论】: