Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   Вебмастеру (http://forum.oszone.net/forumdisplay.php?f=22)
-   -   Сохранение значения при рефреше php (http://forum.oszone.net/showthread.php?t=251619)

salat 16-01-2013 20:09 2068367

Сохранение значения при рефреше php
 
Есть простенький чат на 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;)} </style>
<script src="script3.js"></script>
</head>
<body>
<form method="post" name="chat" OnSubmit="return CheckMsg(this);">
<div align=center class=d2>&nbsp;&nbsp;<b>Имя:&nbsp;<input class=sb type="text" name="person" maxlength="80" value="<?php echo $person; ?>" style="width:80px" /></b>&nbsp;<input class=sb name="msg" type="text" maxlength="255" style="width:255px" />&nbsp;&nbsp;<input class=sb2 type="submit" value="Отправить">&nbsp;&nbsp;<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 } ?>


Время: 16:43.

Время: 16:43.
© OSzone.net 2001-