<?php
$amount= "10" ;
if (!isset($_GET["action"]))
{
}
elseif ($_GET["action"] == "write") // etc.
{
header('location: succes.php');
$data = '' . PHP_EOL;
$file = fopen('plugins/comments/comments/comments.txt', 'a');
$message = str_replace("\r", '', $message);
$message = str_replace("\n", '{{', $_GET['message']);
fwrite($file, $_GET['name'] . '||' . date('d-m-Y') . '||' .
$message . $data);
fclose($file);
}
$start = (isset($_GET['start']) ? $_GET['start'] : 0);
$gastenboek = Array();
$gastenboek = file('plugins/comments/comments/comments.txt');
?>
<fieldset class="comments">
<legend class="pm">Reacties</legend>
<div style="float:right;">Aantal reacties:
<b>
<?php echo min($start+$amount,sizeof($gastenboek)); ?>
</b>
</div>
<TABLE class="comments" width="100%">
<?PHP
$gastenboek=array_reverse($gastenboek);
for ($i = $start; $i < $start+$amount && $i < sizeof($gastenboek); $i++)
{
list($name, $date, $message) = explode('||', $gastenboek[$i]);
$message=str_replace('{{',"\n",$message);
echo '
<TR>
<TD class="comments">
<div style="float:left;">
<B>'.$name.'</B>
</div>
<div style="float:right;">
(<i>'.$date.'</i>)
</div><br>
<p>' . str_replace("\n", '<BR>', htmlspecialchars($message)) .
'</p>
</TD>
</TR>'."\n";
}
?>
</TABLE>
</fieldset>
<br>
<fieldset class="pm">
<legend class="pm">Plaats een reactie</legend>
<FORM action="index.php" method="GET" onSubmit="return validate(this);"
name="comments" id="comments">
<INPUT type="hidden" name="action" value="write">
<p class="pm">Naam: </p>
<INPUT type="text" name="name" size="30" style="width:300px;" required><br>
<p class="pm2">Reactie: </p>
<TEXTAREA class="message" name="message" id="message" cols="46" rows="5" required>
</TEXTAREA>
<br>
<INPUT type="submit" value="Reactie toevoegen">
</FORM>
</fieldset>
我想知道这个脚本是否可以转换为使用POST而不是GET。
提前致谢。
答案 0 :(得分:1)
将表单方法从method="get"
更改为method="post"
。
然后,您必须将$_GET
更改为$_POST
。