Solved

Recording a click thru

Posted on 2007-11-30
2
205 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

803 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