The Mudcat Café TM
Thread #93749   Message #1808697
Posted By: GUEST,Jon
13-Aug-06 - 08:58 AM
Thread Name: BS: mudchat, why is there never anyone there
Subject: RE: BS: mudchat, why is there never anyone there
Off the top of my head, the simplest extension to my crude system would be.

input.php: user message input.
Code:

<?
if (isset($_POST["quit"]))
    {
    require("db.php");
    $SQL = "INSERT INTO message (username, message)
    VALUES ('" . $_POST["username"] . "', 'has left the chat')";
    mysql_query($SQL);
    header("Location: login.php");
    exit;
    }

if (isset($_POST["send"]))
    {
    require("db.php");
    $SQL = "INSERT INTO message (username, message)
    VALUES ('" . $_POST["username"] . "', '" . $_POST["message"] . "')";
    mysql_query($SQL);
    }
?>
<html>
<head>
</head>
<body>   
<form action="input.php" method="post">
<input type="hidden" name="username" value="<?echo $_REQUEST["username"]?>">
<input name="message" size="80" >
<input type="submit" name="send" value="send">
<input type="submit" name="quit" value="quit">
</form>
</body>
</html>

That might work providing a user left by clicking the "quit" button. Obviously you could etend things say with a right hand frame listing users and making queries to the database, etc.