Jump to content


This topic is now archived and is closed to further replies.


Several questions regarding chat script

Recommended Posts

Ok I have several questions regarding a live support Script that I am creating. Here is the code that I have so far. The layout is very simple. This is just for testing purposes.

[b]The chat login[/b]

if (isset($nick)) {
  if (empty($nick)) {
      $error = "nick";
$sql = mysql_query("INSERT INTO chat(nick) VALUES('$nick')") or die (mysql_error());

if (!$sql) {
    $error = "sql";
$filename = "$nick.html";
$handle = fopen($filename, "x+b");
$body = "<meta http-equiv=\"refresh\" content=\"2\">
<meta name=\"robots\" content=\"noindex\">
Welcome <b>$nick</b>, an operator will be with you shortly.
<!--Start of chat-->
<!--end of chat-->
fwrite($handle, $body);

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>

<p><h3>Please Enter your nick name</h3></p>
if ($error == "nick") {
    echo "You did not enter a nick name";
if ($error == "sql") {
    echo "Something when wrong with the MySQL query.";
<form action="enter_chat.php" method="post">
<input type="text" name="nick" size="20">
<input type="submit" name="submit" value="Submit">


ok I guess I will start with the questions about this script.

First, how can I retrieve the chat_id from the data base so that I may create a html file like this [b]$nick.$chat_id.html[/b]

Second, is a refresh rate of 2 seconds to much? Can I make it refresh, on both the client side and operator side, when a new line is added?

Third, when I have enough messages where you need to scroll down to see the last message. Every time the page refreshes it starts me over at the top line again. Is there a way that, when it refreshes, I can make it go to the bottom of the html file.


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.