Im tryin counts the number of times the link was copied, and then redirected to the affiliate site with this identifier. I managed to make a part of the click where it updates 1 in the database each time the link is clicked, but has problems with the redirection part, I send the identifier to track.php and then retrieve the identifier there, but I have a redirection problem from there. I have affiliate_link in the database and url is stored there. any help would be great.
on track.php
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/market/core/init.php';
if(isset($_GET['id'])){
$id = is_numeric($_GET['id']);
$db->query("UPDATE credit_card_offers SET count_click = count_click + 1 WHERE id = '$id'");
header('Location: How_to_call_Affiliate_link_here_form_database?');
}
?>
at index.php.
<a href="track.php?id=<?= $product['id']; ?>">See Deal</a>
sql dump
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
;
;
;
;
CREATE TABLE `credit_card_offers` (
`id` int(11) NOT NULL,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`brand` int(11) NOT NULL,
`categories` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`image` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`description` text COLLATE utf8_unicode_ci NOT NULL,
`balance_transfers` text COLLATE utf8_unicode_ci NOT NULL,
`purchases` text COLLATE utf8_unicode_ci NOT NULL,
`representative_apr` text COLLATE utf8_unicode_ci NOT NULL,
`representative_example` text COLLATE utf8_unicode_ci NOT NULL,
`affiliate_link` text COLLATE utf8_unicode_ci NOT NULL,
`featured` tinyint(4) NOT NULL DEFAULT '0',
`count_click` int(255) NOT NULL DEFAULT '0',
`deleted` tinyint(4) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `credit_card_offers` (`id`, `title`, `brand`, `categories`, `image`, `description`, `balance_transfers`, `purchases`, `representative_apr`, `representative_example`, `affiliate_link`, `featured`, `count_click`, `deleted`) VALUES
(15, 'Barclaycard Platinum With Balance Transfer (25/25 Card)', 19, '19', '/market/images/products/5ac13b939568b60b71eb9fb1fa4d82df.png', 'A 2.5% fee is applied to balance transfers but a refund reduces this to 1.49% within 2 days (T&Cs apply). Transfer a balance within 60 days of opening an account to get the 0% deal; otherwise the rate will be 18.9% p.a. variable with no fee. ', '0% for 25 months with a 1.49% fee', '0% for 25 months', '18.9% APR', 'Representative Example: The standard interest rate on purchases is 18.9% p.a. (variable), so if you borrow £1,200 the Representative APR will be 18.9% APR (variable). ', 'https://www.barclaycard.co.uk/personal/platinum', 0, 0, 0);
ALTER TABLE `credit_card_offers`
ADD PRIMARY KEY (`id`);
ALTER TABLE `credit_card_offers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
;
;
;