I'm writing a redirect script in PHP that will insert info about the click in a MySQL database.
Will it always insert the info if the database if I put the header() function before the insert? I want to do it this way to make the redirect as fast as possible.
$location = "Location: http://www.example.com";
header($location);
$sql = "INSERT INTO tracking (info) VALUES ('$info')";
$result = @mysql_query($sql, $con) or die(mysql_error());
I have tested it and it does insert the info in the database. However, my main concern is if the server is running slow and the header() function completes before the insert takes place will the script end without inserting the info in the database.
Or will the script complete regardless?