Solved

Recording a click thru

Posted on 2007-11-30
2
207 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
ID: 20386910
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
ID: 20387469
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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

820 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