Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-03-2012, 08:21 PM   PM User | #1
hans_cellc
New Coder

 
Join Date: Oct 2011
Posts: 92
Thanks: 38
Thanked 0 Times in 0 Posts
hans_cellc is an unknown quantity at this point
Question Link hit counter

I have the following codes and it seems to work well but when exiting the site and re-entering it resets the values to 0 again.
I am not sure how to proceed with this, been considering cookies but what if the user clears there cookies, I then looked at PHP but not understanding that to well at this stage.
This was posted on the Javascript forum and they refered me here.

Javascript

Code:
// Function to count clicks on links
var clicks1 = 0;
var clicks2 = 0;
var clicks3 = 0;
var clicks4 = 0;

function link1(){
    document.getElementById('clicked1').value = ++clicks1;
}
function link2(){
    document.getElementById('clicked2').value = ++clicks2;
}
function link3(){
    document.getElementById('clicked3').value = ++clicks3;
}
function link4(){
    document.getElementById('clicked4').value = ++clicks4;
}
HTML Code:

Code:
<tr valign="middle" align="center"><td colspan="1"><a target="_blank" href="http://mistiquestormelectronics.webs.com/" onclick="link1()"><img src="site_graphics/reinet.jpg" alt="Mistique Storm" width="120" height="90" /></a></td>
<td colspan="2" align="left"><p>For all your Electronic equipment needs.</p></td>
<td colspan="1" width="8%"><input id="clicked1" style="color: #000000; font-weight:bold; border-style: none; font-family: arial; background-color: #00FF00; text-align: center;" readonly="readonly" size="10" onfocus="this.blur();" value="0" ></td></tr>
Javascript forum advised me to use serverside cookie PHP or ASP dont know either but done some PHP(minimal), Please help.

The link on what I want to do is at:
www.sayorkies.co.za/friends.html
I want it to show all users count that clicked the link and no unique users, also preferably with no mysql.
hans_cellc is offline   Reply With Quote
Old 01-03-2012, 09:50 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Their site doesn't save the clicks either, so why would you want it like theirs?

You want the clicks saved permanently for every user?
And if that user comes back in 4 days, they see the same clicks as before?

The problem with IP is that it's not always the same.
Each time you connect with an ISP, it may give you a slightly different IP address.

Cookies might be more reliable, but people can erase them.

The only SURE way to do it is to require the user to log-in.
And then, you'll be using MySQL. But that's the very best way.
And it doesn't matter what computer the user is on ... when they
log-in, the clicks are counted and stay counted.

Other than a user log-in with password, you have no way to reliably monitor clicks.
mlseim is offline   Reply With Quote
Old 01-04-2012, 05:16 AM   PM User | #3
hans_cellc
New Coder

 
Join Date: Oct 2011
Posts: 92
Thanks: 38
Thanked 0 Times in 0 Posts
hans_cellc is an unknown quantity at this point
Sorry the page I gave as an example is the actual site I am working on, that is why it does not save. This website was a Javascript assignment and now I am fine tuning certain aspects but am totally new to PHP and never worked with MySql.
What would be my starting point?

Thanks
hans_cellc is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:04 PM.


Advertisement
Log in to turn off these ads.