I am stuck with my php code. Parent php page reload again after header() works, Here is my code
<?php
$mysqli = new mysqli("localhost", "root", "root", "testing");
/* check connection */
if ($mysqli->connect_errno) {
printf("Connect failed: %s
", $mysqli->connect_error);
exit();
}
$sql ="update test set hit_count = hit_count+1";
$result = $mysqli->query($sql);
header('Location: http://www.google.com/');
die();
?>
Here some times i got 2 hit_count from db. How it works, i added die() after header().
You should not output text before using header redirects as seen on the code below:
/* Select queries return a resultset */
if ($result = $mysqli->query($sql)) {
printf("updated");
}else{
echo "failed";
}