r_hosseinkhani
Member
چه جورd ميشه با php يك guest book ساخت.
باتشكر
باتشكر
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Guestbook</title>
</head>
<body bgcolor="#3366CC">
<?php
// if form was submitted, write texts to file
if (isset($_POST['submit'])){
$fp = fopen('guestbook.txt', 'a') or die('error in opening file');
$str='<p><b>Name:</b> '.$_POST['name'].'<br><b>Comment:</b><br> '.nl2br($_POST['comment']).'</p><hr>';
fputs($fp, $str);
fclose($fp);
}
// print all last comments
$fp = fopen('guestbook.txt', 'r') or die('error in opening file');
while(!feof($fp)){
echo fgets($fp);
}
fclose($fp);
?>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%">
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p align="center">
<b>Your Name: </b><input type="text" name="name" size="20"></p>
<p><b>Comment:</b><br>
<textarea rows="10" name="comment" cols="30"></textarea></p>
<p align="center"><input type="submit" value="Submit" name="submit"> <input type="reset" value="Reset"></p>
</form>
</td>
</tr>
</table>
</center>
</div>
</body>
</html>