Jump to content

гостевая книга


bobibobi
 Share

Recommended Posts

я хочу установыть гостевую книгу но гдето наверно есть ошибка

вот мой код:

<html>
<head>
<title>guest book</title>
</head>
<body>
<div align="center">
<table border="1" cellspacing="0" cellpadding="0" width="600">
<?
$arr = file("gb.txt");
for ($i = 0; $i < count($arr); $i=$i+4)
{
echo "<tr><td align="left">";
echo "Login:".$arr[$i]."
";
echo "E-mail:".$arr[$i+1]."
";
echo "</td></tr><tr><td>";
echo $arr[$i+3];
echo "</td></tr>";
echo "<tr><td>
</td></tr>";
}
?>
</table>
<form action="gb.php" method="post">
<input type="hidden" name="action" value="add" />
<table>
<tr>
<td colspan="2" align="center"><b>add comment</b></td>
</tr>
<tr>
<td>login:</td><td><input type="text" name="login" /></td>
</tr>
<tr>
<td>e-mail:</td><td><input type="text" name="email" /></td>
</tr>

<tr>
<td valign="top">comment</td><td><textarea rows="10" cols="50" name="message"></textarea></td>
</tr>
<tr>
<td align="right" colspan="2"><input type="submit" value="add" /></td>
</tr>
</table>
</form>
</body>
</html>

и код gb.php:

<?
if ($_POST['action'] == 'add')
{
$_POST['login'] = trim($_POST['login']);
$_POST['email'] = trim($_POST['email']);
$_POST['message'] = trim($_POST['message']);
$_POST['message'] = nl2br($_POST['message']);
if (!empty($_POST['login']) && !empty($_POST['message']))
{
$fp = fopen('gb.txt','a+');
fputs($fp,$_POST['login']."n");
fputs($fp,$_POST['email']."n");
fputs($fp,$_POST['message']."n");
fclose($fp);
}
}
?>

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy