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
https://forums.phpfreaks.com/topic/78724-solved-a-chat-script/
Share on other sites

Archived

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

×
×
  • 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.