8 Replies - 2679 Views - Last Post: 12 April 2012 - 07:07 AM Rate Topic: -----

#1 TKEYI60  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 26-April 11

Check if link clicked php/html

Posted 11 April 2012 - 07:30 PM

Hey all,

Working on a project, and I have my entire page(s) typed out in html so that it looks like a jeopardy board. Category scores link to questions, that link to answers that link back to the main jeopardy board.

I'm trying to figure out if I can create some php code that allows me to keep track of the links clicked so a user cannot reclick the link and when all 25 links have been clicked (when you return to the main board after the 25th question) it will redirect to a "thanks for playing" page.

Can anyone point me in a beginning direction? I have no idea where to start, all my pages are .html, and i've tried looking everywhere but nothing makes sense. And to clarify, my .html are nested tables so each cell is
<td><a href="qc100.html">100</a></td>


Thanks in advance!!

Is This A Good Question/Topic? 0
  • +

Replies To: Check if link clicked php/html

#2 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2960
  • View blog
  • Posts: 10,186
  • Joined: 08-August 08

Re: Check if link clicked php/html

Posted 11 April 2012 - 08:17 PM

HTML is static and client side. PHP is dynamic and server side. With PHP you could build the HTML pages on the fly and using sessions you could keep track of what links have been clicked. That way when a page is refreshed you might not show previously clicked links or show them but remove/alter the hyperlink.

By the way, that doesn't look like tabular data so you probably should not be using a table.
Was This Post Helpful? 1
  • +
  • -

#3 sas1ni69  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 85
  • View blog
  • Posts: 431
  • Joined: 04-December 08

Re: Check if link clicked php/html

Posted 11 April 2012 - 09:11 PM

May I suggest Javascript?
Was This Post Helpful? 1
  • +
  • -

#4 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3530
  • View blog
  • Posts: 10,180
  • Joined: 08-June 10

Re: Check if link clicked php/html

Posted 11 April 2012 - 10:43 PM

you may, but Javascript may as well be disabled.

in the end it is more a matter of preference whether you do that in PHP, JS or using both.

if youíre going for PHP, youíll have to look into Sessions. all your pages have to be PHP files and in your PHP script you would have to eliminate (or rather omit) the links to pages already answered.
Was This Post Helpful? 1
  • +
  • -

#5 Roachz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 12-April 12

Re: Check if link clicked php/html

Posted 12 April 2012 - 12:33 AM

Normally you can't see if a link is clicked in PHP. Unless you make a redirect script. For example
Link.php?goTo=http://www.originallink.com; and you save the goTo variable to the database. This method is used by many search engines (google.com), but they do it a little more sneakier and advanced.

Good luck.
Was This Post Helpful? 1
  • +
  • -

#6 sas1ni69  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 85
  • View blog
  • Posts: 431
  • Joined: 04-December 08

Re: Check if link clicked php/html

Posted 12 April 2012 - 12:38 AM

View PostDormilich, on 12 April 2012 - 01:43 PM, said:

you may, but Javascript may as well be disabled.

in the end it is more a matter of preference whether you do that in PHP, JS or using both.

if youíre going for PHP, youíll have to look into Sessions. all your pages have to be PHP files and in your PHP script you would have to eliminate (or rather omit) the links to pages already answered.


Didn't think about that. When is it safe to assume that JS wouldn't be turned off? Or should we just put a check first?
Was This Post Helpful? 0
  • +
  • -

#7 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3530
  • View blog
  • Posts: 10,180
  • Joined: 08-June 10

Re: Check if link clicked php/html

Posted 12 April 2012 - 01:29 AM

you canít really make any assumptions whether JS is on or off, since that is mostly a decision by the respective user.

however, if JS is off, you canít make any test for it. either you tell the user he needs JS or you code a fallback (in PHP) and use JS as "progressive enhancement" (would make most sense if you use a JS/PHP combination anyway).
Was This Post Helpful? 1
  • +
  • -

#8 sas1ni69  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 85
  • View blog
  • Posts: 431
  • Joined: 04-December 08

Re: Check if link clicked php/html

Posted 12 April 2012 - 02:13 AM

Thanks a lot Dormilich, I'll definitely keep it in mind for future reference.
Was This Post Helpful? 0
  • +
  • -

#9 TKEYI60  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 26-April 11

Re: Check if link clicked php/html

Posted 12 April 2012 - 07:07 AM

Thanks alot for all the advice!! I'll test out a few of these options and go from there.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1