I'm trying to do a PHP redirect after my content has executed, however I cannot get the code to execute.
If I load this up, it redirects the page but doesn't insert anything to the database. If I comment out the header redirect line, it enters the data into my database.
How can I get the PHP to run and execute, and then redirect the page?
<?php require("gplus.php"); ?>
<?php require("database.php");?>
<?php if(isset($personMarkup)): ?>
<?php
$checkuser = "SELECT gid FROM user WHERE gid = '$id'";
$updateuser = "UPDATE user SET name = '$name', pic = '$img' WHERE gid = '$id'";
$adduser = "INSERT INTO user (gid, name, pic) VALUES ('$id','$name','$img')";
$checkuserrlt = mysqli_query($con, $checkuser);
if(mysqli_num_rows($checkuserrlt) > 0) {
$result = mysqli_query($con, $updateuser) or die(mysqli_error());
} else {
$result = mysqli_query($con, $adduser) or die(mysqli_error());
}
?>
<?php endif ?>
<?
mysqli_close($con);
?>
<?php
header( 'Location: http://google.com' );
exit();
?>