Hello and thanks in advance for any suggestions you can lend.
What I am trying to accomplish: When a user clicks a link I want to add an auto-increment id, clicked URL and time stamp to the database and then send them to the URL links landing page.
The problem I am having: When the link is clicked the URL is not added to the database and the redirect also fails.
Here is the code I am working on:
ad_click_tracking.php
<?php
include ("admin/includes/connect.php");
mysql_select_db("$database") or die(mysql_error());
//Collecting the destination URL from the clicked link
$redirect = mysql_real_escape_string($_GET['page']);
//Insert destination URL and time stamp into MySQL
$page_insert = mysql_query("INSERT INTO ad_click_tracking (`url`, `date`) VALUES ('$redirect', now())") or die(mysql_error());
//Redirecting user to the clicked URL
header("Location: $redirect");
//Debugging to see if we collected the URL
echo "Redirect URL: $redirect";
?>
header.php (Contains the links to be tracked - the first link is internal the second link is external)
<a href="http://recyclingkansascity.com/ad_click_tracking.php?page="index.php" target="_blank"><img src="/images/header_banner/recycling_kansas_city_header.png" width="620px" height="340px" alt="Recycling Banner" title="Recycling Kansas City"></a></li>
<a href="http://recyclingkansascity.com/ad_click_tracking.php?page="http://paws4autism.org" target="_blank"><img src="/images/header_banner/funny_bunny_5k_autism_egg_hunt.png" width="620px" height="340px" alt="Paws 4 Autism" title="Paws 4 Autism Easter Event"></a></li>
When I click the internal or external link the browser displays the URL as recyclingkansascity.com/ad_click_tracking.php?page= and then when I check the database the id has been auto-incremented and the timestamp is inserted but the URL is null. For some reason the ($_GET['page']) seems to be failing to grab the page URL and I have not been able to figure out why as of yet. I read through relevant "similar questions" and was not able to find an answer.