PHP Chat System ??

Discussion in 'PHP' started by xkaser101, Aug 15, 2011.

  1. #1
    Hello, I am only inches away from Finishing up my website until I had an Issue creating a simple chat system for my website,

    I've Searched all over the place and it seems that the ONLY way is to use AJAX ( I am a total newbie to Ajax :confused: )

    Is there any way to create a simple Database Driven Chat with PHP/MySql/Javascript ?

    If yes, can you guide me with a simple code to start with ?... or better yet a tutorial.


    Thanks in advance,
    Kind Regards,
    Issa Shamoun.
     
    xkaser101, Aug 15, 2011 IP
  2. iBank ™

    iBank ™ Peon

    Messages:
    63
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    0
    #2
    If you do not know AJAX, you do not know Javascript enough well to begin with.
     
    iBank ™, Aug 15, 2011 IP
  3. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #3
    If you want to use Ajax, which is pretty much the only way here, I, and not only I, recommend using Jquery (http://jquery.com/) which is a pretty neat javascript library.

    For a chat application I recommend using json to communicate. (Using the json_encode function in php) If you want to fetch a variable from php, this script will do
    
    $.POST("url/toscript.php", {"postvar1": "value","postvar2":"value","etc":"value"}, function(data){
     //data is now the Json code, echoed by the php file.
     var variable = eval("("+data+")");
     
    }); 
    
    Code (markup):
    It really isn't that difficult.
     
    ssmm987, Aug 16, 2011 IP
  4. freelanceinphp

    freelanceinphp Member

    Messages:
    134
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    48
    #4
    freelanceinphp, Aug 18, 2011 IP
  5. xkaser101

    xkaser101 Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    what is json ? yet another thing to add on for my learning curve ? :(
     
    xkaser101, Aug 21, 2011 IP
  6. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #6
    JSON is JavaScript Object Notation. A method of representing data.

    As far as AJAX, jQuery makes it trivial:
    $.ajax({
       url: "serverside-code.php",
       context: document.body,
       success: function(){
         //whatever you want done when the data returns from the server;
       } });
    Code (markup):
    But as freelanceinphp said, there are many PHP chat apps you can find on the web.
     
    Rukbat, Aug 22, 2011 IP