Home page redirection in php long polling
Reply: 1

page redirection in php long polling

user3636571
1#
user3636571 Published in 2018-01-12 03:56:10Z

I am using php-long-polling to display data to user on instant basis in one of my projects. I got the script from here https://github.com/panique/php-long-polling When counter sets to 1 it has to redirect to some other page. This redirection is not happening in server.php script.

ob_start();
set_time_limit(0);

include('includes/sessions.php');
while (true) {
    $last_ajax_call = isset($_GET['timestamp']) ? (int)$_GET['timestamp'] : null;
$id = $_GET['id'];

       $sql = "SELECT max(gid) FROM grp WHERE gid=".$id."";
        $result = mysqli_query($con, $sql);
    if ($last_ajax_call == null || $last_change_in_data_file > $last_ajax_call) {
      $sql = "SELECT is_set, start FROM grp WHERE gid =".$id."";
        $result = mysqli_query($con, $sql);
        if (mysqli_num_rows($result) > 0) {

            while($row = mysqli_fetch_assoc($result)) {


              if(($row['is_set'] == 1) && ($row['start'] == 1))
               {
//Here redirection should happen
$data .= "<script> window.location.href = './result.php?id=".$id."</script>";
}
}
}

I tried

header("location:result.php?id=$id");
exit();

But nothing did work. why these redirection not working.

Jonny
2#
Jonny Reply to 2018-01-12 04:21:03Z

Try to change your PHP variable to this. Setting sessions or cookies is in my opinion is the most secure way to transfer data with PHP. Don't put sensitive info in a URL string.

header("location:result.php?id=".$id."");
exit();
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.316737 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO