Solved

Recording a click thru

Posted on 2007-11-30
2
203 Views
Last Modified: 2013-12-12
I am trying to figure out a good way to record a click thru on my new site.  I understand the concepts of having a second page which is redirected to that records the click, but I am stuck as to how to post across other data which I would also need to store (such as what link was clicked).

Here is the scenario.

The site lists advertisements for my clients.  Each advertisement is in the form of a product which they have listed on their site (i.e. on their e-commerce store).  My visitors find a product they are interested in and click to be taken to the site selling that product.  All nice and simple..

However, when they click the link and get redirected to my "clickthru.php" page (for example), how do I pass to the clickthru.php script what the product ID is for that particular item?

(I have actually just realised that I could actually use $_GET and embed the information in the URL calling my "clickthru.php" which would pass the data but my preference is very very much on keeping as much data $_POSTed rather than the more insecure $_GET (although I do escape all mysql variables)).

Just to check though, is there anyway to post this without creating a <FORM> for the links.

Cheers

Steve
0
Comment
Question by:ParadyneDesigns
2 Comments
 
LVL 21

Accepted Solution

by:
nizsmo earned 125 total points
Comment Utility
Hi Steve

How about using session variables to pass through the data?
Something like this would work:

<?php
session_start();
// This has to be present on every page you want to access the variable

$_SESSION["click_url"] = "http://www.myurl.com";

//...more of your code...
session_write_close();
?>


then in your other pages you can access the click_url variable anywhere:
<?php
session_start();
echo $_SESSION["click_url"];
//.. more of your code..
session_write_close();
?>


Hope this shows you another way of going about it, apart from GET and POST methods which may be unreliable at times.
0
 
LVL 20

Assisted Solution

by:steelseth12
steelseth12 earned 125 total points
Comment Utility
You could do it with javascript but its not worth it ... _POST is as insecure as _GET .....
What i do is send just an id ....  e.g clickthru.php?cid=43232 and get all the information from the database from there on.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Creating and Managing Databases with phpMyAdmin in cPanel.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now