Simple, text-based PHP chat system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.4 KiB

header("X-Frame-Options: DENY");
header("Content-Security-Policy: frame-ancestors 'none'", false);
<!DOCTYPE html>
<meta charset="utf-8" />
<meta name=viewport content="width=device-width, initial-scale=1">
<title>Simple Chat</title>
<link rel="shortcut icon" type="image/png" href="chat.png"/>
<link href="style.css" rel="stylesheet" />
<noscript><a href="nojs.php">No JavaScript? Try the JS-free page here</a></noscript>
<div id="information">
<p><strong>Note:</strong> all times are in UTC.</p>
<div id="messages">
$chat = fopen("chat.txt", "a+") or die("Error upon opening file");
while(!feof($chat)) {
echo "<div class=\"message\">" . fgets($chat) ."</div>";
echo fread($chat,filesize("chat.txt"));
<input type="text" id="name" <?php if ($_SESSION['name'] !== null) {echo 'value=' . $_SESSION['name'];} ?> />
<input type="text" id="message" autofocus />
<button onclick="message()">Send</button>
<br /><br />
<a href="#">Simple Chat</a> code &copy; Josias 2018, 2019, 2020. <a href="">See source code</a>
<script src="script.js"></script>