Jump to content

Php Chat


G.kanojiya

Recommended Posts

Hi All...

 

I am facing some problem while coding chat system.....my problem is that whenever i refresh the chat page the last message stored in the url by the current user displays again....its showing messages from the other users also but its keep on repeating the messages of the current user logged in,in the browser.....i am using post for all....do i need to try something else or any new way etc....if anybody have suggestions and solutions for the above mentioned problem then plz do help me out...thank you...:)

Link to comment
Share on other sites

There are many chat programs out there which use mysql etc if you just want a chat program, however if you are doing it for a learning exercise, remember that PHP is a server-side language and you will probably have to use javascript or flash to handle the client browser part. If you need specific help on a specific problem, then you need to post a specific snippit of code (not the whole thing but the part ~10-15 lines which is not working)

Link to comment
Share on other sites

Yes ocpaul20, I am doing it for learning purpose.........and here are the lines where think the problem may be....

<form method="post" action="">
<table width="200" border="1">
  
  <tr>
    <td>Message:</td>
    <td>
    <input type="text" name="des" placeholder="Type Something.."/></td>
  </tr>
  
  <tr>
    <td></td>
    <td><input type="submit" name="sub" value="Send"/></td>
  </tr>
</table>
</form>


$des=$_POST['des'];

if(isset($_POST['sub']))
{
$cht=new forms();
$arr=$cht->sndAcptMsg($des);
}

 

Where 'sndAcptMsg' is a function containing all the queries...please have a look if i am doing something wrong.....any help greatly appreciated....:)

Link to comment
Share on other sites

Well, I normally put the test of POST at the top and then the HTML at the bottom. That way I can just drop through if the form has not been submitted.

To begin with, I would probably hard code some messages rather than getting them from the database and then when the logic was correct, I would add parts of the program together. That way I would know the thing was working as I was building it. Anything not working would be the part I slotted in last.

 

There are PHP tutorials which build up a chat client/server application. They explain what each step does. Look up sockets for example. You can always add the database part after you have got the client/server sockets talking to each other.

Have fun.

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.