April 4, 2012

Check which user clicked on which link

Question by user1295105

I have few links on my website, how can I record into database which user clicked on which link. I have records of the links into database and users. I have created a table in which there will be userid, linkid. But im not sure how to code this php. Any ideas?

EDIT:

<a hef="page.php?id=27">pagename</a>

the link above goes to a page where the link is counted and it looks for the url into the database and redirects to that page. But i want to see which user clicked it.

Answer by Starx

Most easiest way would be to pass a link-identifier as the URI parameter

An example:

<a href="page.php?id=27&clicked=pagename">pagename</a>

Now you can get what the user clicked by checking $_GET['clicked']


It seems I misunderstood the question

You can do this on your page.php

$id = $_GET['id']; //Get the page id
$userid = $_SESSION['id']; // Get the user id if stored in session

//Do something with the user id

header("location: ..."); //redirect to a different place
exit;
March 31, 2012

User specific stylesheet?

Question by user1305075

I have a website where a user chooses a template of their choice for their web page.

Once they’ve selected the template, I want them to be able to change some of the styles such as the font colour etc?

Is there a way I could do this?

I thought of perhaps storing the user specified stuff in a field in a database and then retrieve it and display as internal CSS?

Answer by Monojit

You may use a user.css (initially empty) for each user and then add data provided by user with !important override.

Answer by Starx

Yes

It is possible. But you will have to rely on Javascript to add the stylesheet, url selected.

Assuming you would be using a link to change the theme, using jQuery, you would do

$('#red').click(function (){
   $('#linktagid').attr('href','user_red.css');
});
...

Please fill the form - I will response as fast as I can!