Есть простенький чат на php без mysql.
После отправки сообщения поле Ник обнуляется.
Подскажите как сохранять это поле через куки чтобы каждый раз при заходе в чат, предыдущий использованный Ник вписывался автоматически.
читать дальше »
<html>
<head>
<meta name="pragma" content="no-cache">
<style> input.sb {color:#5B5B5B;font: 12px Arial;height:20px;border:1px #414141 solid;background-image:url("./images/fbg2.gif")} input.sb2 { margin: 0px;font: 12px Arial; background:#9bc3e6 url("./images/fbg4.gif") repeat-x; color: black; cursor:hand
![Wink](images/smilies/wink.gif)
} </style>
<script src="script3.js"></script>
</head>
<body>
<form method="post" name="chat" OnSubmit="return CheckMsg(this);">
<div align=center class=d2> <b>Имя: <input class=sb type="text" name="person" maxlength="80" value="<?php echo $person; ?>" style="width:80px" /></b> <input class=sb name="msg" type="text" maxlength="255" style="width:255px" /> <input class=sb2 type="submit" value="Отправить"> <img width=15 height=15 src="./images/refresh.gif" OnMouseOver='this.style.cursor="hand";' alt="Обновить Чат !" OnClick="parent.parent.bottom.self.location.href = parent.parent.bottom.document.location.href;"></div> <?php if (isset($_POST['msg'])) include "write_msg.php"; ?>
</body>
</html>
читать дальше »
<?php
include "option.php";
$fl = file($msg_file);
$count_fl = count($fl);
$msg = stripslashes(trim($_POST['msg']));
$person = trim($_POST['person']);
if (($msg != "") && ($person != ""))
{
if ($count_fl >= $msg_count)
{
$fw = fopen($msg_file, "w");
for($i=1;$i<$msg_count;$i++) fwrite($fw, trim($fl[$i])."\r\n");
}
$time = strftime("%H:%M:%S", time());
$fp = fopen($msg_file, "a+");
$fw = fwrite($fp, $person."¤".$time."¤".$msg."\r\n");
fclose($fp); ?>
<script>parent.parent.bottom.self.location.href = parent.parent.bottom.document.location.href;</script>
<?php } ?>