Jump to content

Several questions regarding chat script


tomfmason

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]

[code=php:0]<?php
if (isset($nick)) {
  if (empty($nick)) {
      $error = "nick";
}  
include('db.php');
$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\">
<p>
Welcome <b>$nick</b>, an operator will be with you shortly.
</p>
<!--Start of chat-->
<!--end of chat-->
</p>";
fwrite($handle, $body);
fclose($handle);
include('chat.php');

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

<body>
<p><h3>Please Enter your nick name</h3></p>
<?php
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">
</form>

</body>
</html>[/code]


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.


Thanks,
Tom


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.