Jump to content

[SOLVED] A chat script


Demont

Recommended Posts

I've made an attempt at a chat script, but it isn't performing exactly how I want. Yes, I am a relative newbie to PHP.

I've spent hours on Hot Scripts looking for something, but nothing I found meets what I need.

 

What this chat script is for is for a web based MUD. I've updated the code, but I am running into a snag...

 

 

<!-- Begin Chat Script -->
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }mysql_select_db("DB", $con);$sql="INSERT INTO Contacts (chat)
VALUES
('$_POST[chat]')";if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
$query = mysql_query("SELECT chat FROM Contacts");       
        // Creates an array of items with keys corresponding to table columns... 
while($row = mysql_fetch_array($query)){ 
    //Create the HTML table 
echo "$username said, ".$row[chat].".<br>";
} 

  ?>


<br><br><br><br><br><br><br><br>

<?php
include("more_footer.php");
?>
<form action="members.php" method="post">
<br />
<input type="text" name="chat"><br />
<input type="submit" value="Submit">
</form>
<!-- End chat Script -->

 

What I am trying to attempt, it to have the 'chat' displayed on the screen so all users see it, but so that it is like;

 

'Username said, text here.'

'Username said to, text here.'

 

And such like that, so that say if a user supplies a command into an input field like /say, or /say to user, it will show the output like I demonstated above, and so that if the field is empty, it doesn't display any thing.

 

You can go to http://loria.freehostia.com and see what I mean with the LOGIN-test and PASSWORD-test.

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.