I want to redirect to index.html?id=div2 when the if condition is statisfied. And if not, then it should reload the page.
How do I do that?
if($checkAll > 0){
    // Redirect to index.html?id=div2  
} else{
    //Reload page
}
Thanks!
I want to redirect to index.html?id=div2 when the if condition is statisfied. And if not, then it should reload the page.
How do I do that?
if($checkAll > 0){
    // Redirect to index.html?id=div2  
} else{
    //Reload page
}
Thanks!
 
    
    You have to use headers:
if($checkAll > 0){
    header("Location: /index.html?id=div2"); 
} else{
    header("Refresh:0");
}
// die();
 
    
    /* Redirect browser */
header("Location: yourUrl.com");
exit();
it's a good practice to call exit() right after it so that code below it does not get executed.
 
    
    Try this, I use redirect like this.
function redirect_to($location) {
    header("Location: " . $location);
    exit;
}
if($checkAll > 0) {
    $new_id = mysqli_insert_id($connection);
    redirect_to('/index.php?id=' . $new_id);
      } else {
    redirect_to('/index.php');
}
