last day (44 days later) » 

11:32 AM
0
A: What should I put in my updating.php when I need to update users status if online or offline every 5 seconds?

RishabInclude the jquery library to run $ajax <script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script> Only add This code to update user status in the Updating.php. No need to copy complete code. <?php ...

 
and what should I put in the updating.php sir?
 
In updating php you need to add the logic to update the user status, i have made example for that page too
 
I'm a bit confused what to put sir
 
Okay wait will sort out the complete code
I have updated the code verify it
 
I'll comment if its successful :)
I opened 2 accounts in two browsers, chrome and internet explorer, the one account is offline while the two accounts are opened, meaning the updating did not do it every 5 seconds, am I right?
do you need the full code? github.com/patrickesguerra/messaging
 
11:33 AM
Hi i will cehck your code and let you know the changes
 
the things I put in github is still not changed from the code you've given sir
 
okay will verify
hey you still made mistake in your code
 
ohmygod
what is it sir?
 
<?php
require('connection.php');
$user_name=$_SESSION['username'];
$user_id=$_SESSION['user_id'];
if(!isset($_SESSION['user_id'])){
header("LOCATION: index.php");
}else{
$advance_time=time()+15;
$query=mysqli_query($con,"SELECT * FROM status WHERE user_id='$user_id'");
if(mysqli_num_rows($query)>0){
mysqli_query($con,"UPDATE status SET status='$advance_time' WHERE user_id='$user_id'");
}else{
mysqli_query($con,"INSERT INTO status(user_id,status) VALUES ('$user_id','$advance_time')");
}
}
?>
<div id="left-col-container">
And updating.php should be
<?php
require('connection.php');

if(isset($_REQUEST['from_user'])){
$advance_time=time()+15;
$user_id = $_REQUEST['from_user'];
$query=mysqli_query($con,"SELECT * FROM status WHERE user_id='$user_id'");
if(mysqli_num_rows($query)>0){
mysqli_query($con,"UPDATE status SET status='$advance_time' WHERE user_id='$user_id'");
}else{
mysqli_query($con,"INSERT INTO status(user_id,status) VALUES ('$user_id','$advance_time')");
}
?>
 
did it worked in your computer? the updating for 5 secods?
 
11:45 AM
yess
try this code
 
is that the code you gave to the stackoverflow?
 
yes ryt you haven't copied it properly
 
I copied it and that was the result
 
Okay can you give me some time will fixed it
 
Ok sir
 
12:29 PM
Its hard for me, i took 3 weeks already for it I need help
 
1:19 PM
do you have a gmail? I'll send you the better code
 
1:39 PM
can we keep this conversation going?
 
 
2 hours later…
3:59 PM
I updated my hithub with the images for offline or online dot
 
4:25 PM
Hi
Will check your new code now
 
5:06 PM
I have updated the code for both left-col.php and updating.php
<?php
require 'connection.php';
session_start();

$user_name = $_SESSION['username'];
$user_id = $_SESSION['user_id'];
if (!isset($_SESSION['user_id'])) {
header("LOCATION: index.php");
} else {
$advance_time = time() + 15;
$query = mysqli_query($con, "SELECT * FROM status WHERE user_id='$user_id'");
if (mysqli_num_rows($query) > 0) {
mysqli_query($con, "UPDATE status SET status='$advance_time' WHERE user_id='$user_id'");
} else {
mysqli_query($con, "INSERT INTO status(user_id,status) VALUES ('$user_id','$advance_time')");
Code for Updating.php :
<?php
require('connection.php');
session_start();

$user_name = $_SESSION['username'];
$user_id = $_SESSION['user_id'];
if(isset($_REQUEST['from_user'])){
$advance_time=time()+15;
$user_id = $_REQUEST['from_user'];
$query=mysqli_query($con,"SELECT * FROM status WHERE user_id='$user_id'");
if(mysqli_num_rows($query)>0){
mysqli_query($con,"UPDATE status SET status='$advance_time' WHERE user_id='$user_id'");
}
}else{
mysqli_query($con,"INSERT INTO status(user_id,status) VALUES ('$user_id','$advance_time')");
 

  last day (44 days later) »