Location: PHPKode > projects > MyBlog: PHP and MySQL Blog/CMS software > os/chat.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>

<title><?php
include("config/title.txt");
?></title>
</head>
<body>
<h2>Instant Chat</h2>
<a href="chat.php">(Get New Messages)</a><br />
<div style="overflow:auto; height:190px;">
<p>
<?php
$content = file_get_contents("chat.txt");
echo $content;
?>
</p>
</div>
<br />
<?php
if (isset($_COOKIE['super'])) {
echo "<a href=\"chat.php?clear=yes\">(Clear Chat)</a><br />";
}

else {
}


if (isset($_GET['clear'])) {
$file = "chat.txt";
$fileh = fopen($file, 'w') or die("can't open file");
$message = "<b>No Messages</b><br /><br />";
fwrite($fileh, $message);
fclose($fileh);
}

else {
}
?>

<form action="chat.php" method="get">
<textarea name="message">Type your message here</textarea><br />
<input type="submit" value="send" />
</form>
<?php
if (isset($_GET['message']) AND isset($_COOKIE['login'])) {
$old = file_get_contents("chat.txt");
$user = $_COOKIE['login'];
$message = $_GET['message'];
$line = "<br />";
$by = "Posted By: ";

$file = "chat.txt";
$fileh = fopen($file, 'w') or die("can't open file");



fwrite($fileh, $message);
fwrite($fileh, $line);
fwrite($fileh, $by);
fwrite($fileh, $user);
fwrite($fileh, $line);
fwrite($fileh, $line);
fwrite($fileh, $old);
fclose($fileh);
}

elseif (empty($_COOKIE['login'])) {
echo "Please Login to Use Instant Chat";
}
else {
}
?>
</body>
</html>
Return current item: MyBlog: PHP and MySQL Blog/CMS software