0

please i don't know the right way to ask this,but am working on a media so what i want is to display a chat box in all of my webpage once the user open it in my home,like facebook when you are chatting with a friend and you load another page that chat box will still display in the new loaded page,please who can help me i don't know how to start dealing with that.

when friend name is click chat box display but once the page reload or another page is load it diappear but i want to still be active once the user has not log out. index.php

<div id="frnd_chats">
<div id="frnd_chat">
       <div class="u_c_p"><a href="profile.php?id=<?php echo $row["id"]?>">
       <img src="hangout<?php echo $row['photo'];?>"></a></div><div class="u_c_n" id="332">
       <a href="profile.php?id=<?php echo $row["id"]?>" id="<?php echo $row["id"]?>">
       <?php  echo $row["firstname"]."  "."  "."  "."  ".$row["surname"];?></a></div> </div>
</div>

chat.js

$(".u_c_n a").click(function(e){
  e.preventDefault();
   var chatid = this.id;
  //alert(uid);
$.ajax({
  type:'get',
   url:"chat.php",
   data:{chatid:chatid},
   success: function(data){
     $(".msge").html(data);
   }
});
});

chat.php

<?php
session_start();
include 'myhangout.php';
  if(isset($_SESSION["email"])){
        $eml = $_SESSION["email"];

 if(isset($_GET["chatid"])){
  $id = $_GET["chatid"];

$sql = $con->prepare("select * from imt where id=?");
$sql->bind_param('i',$id);
$sql->execute();
$result = $sql->get_result();
$row = $result->fetch_assoc();

echo $user = $row["id"];



?>
  <div class="chat_box">
    <div class="chat_ibox">
        <div class="chat_upic_o_e"><div><img id="upic" title="upload photo" src="hangout<?php echo $row["photo"];?>"></div><div><img id="chat_option" src="option.jpg"> <img id="chat_exit" src="exit.jpg"></div>
        </div>

        <div class="chat_display">

<a href="#">test this work</a>
        </div>
        <div class="chat_typ_txt">
               <form method="" action="">
                      <input type="text" name="message" placeholder="Type a message">
               </form>
        </div>
        <div class="stic_files">
            <div><img id="chat_stickers" src="option.jpg"> <img id="chat_files" src="exit.jpg"></div>
        </div>
    </div>

<?php

}
}
?>
alert
  • 37
  • 4
  • check this https://stackoverflow.com/questions/35473356/is-there-any-javascript-tcp-soket-library-for-php-like-signalr-with-net PHP surely have something like Signalr – Anirudha Gupta Jul 22 '17 at 12:32
  • You need to make ajax request when page loads to see if user has active chat going and to fill in chat box – charlietfl Jul 22 '17 at 12:49

0 Answers0