View Full Version : Using Rollover button to post php, increment counter

Barry McMahon
05-01-2012, 04:12 PM
I would like to use a rollover image to navigate to a new html page while capturing the click and incrementing a counter on the new page. The link on the rollover is no problem. I cannot figure out how to make this work as an incremental counter which would change a total number.

Essentially, I am giving the user a choice of two image rollovers that function as link buttons, when the choice is made, they should be directed to the new page while the counter is increased by one for whichever rollover image they chose. It seems simple enough but it is evading me.

Please help

I am open to spry, php, html javascript or any other solution that an intermediate Dreamweaver user can implement.

Thanks in advance.


05-01-2012, 04:33 PM
There are a series of things you need to do; Have a look at this link & you should be set.


05-01-2012, 08:38 PM
Make sure that your solution is server side (PHP for example)

Barry McMahon
05-02-2012, 09:17 PM
Why does this work to increment the counter, I took almost everything out of the code and it still works, BUT it will NOT increment separately. Please help

<a href="Vote.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('VoteObama','','images/ObamaSelected.png',1)"><img src="images/ObamaVote.png" alt="Vote for Obama" name="VoteObama" width="280" height="280" border="0"><?php
file_put_contents('counter.txt', ((int) file_get_contents('counter.txt')) + 1);?></a>

<a href="Vote.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('VoteRomney','','images/RomneySelected.png',1)"><img src="images/RomneyVote.png" alt="Vote for Romney" name="VoteRomney" width="280" height="280" border="0"><?php
file_put_contents('images/bad.txt', ((int) file_get_contents('images/bad.txt')) + 1);?></a>

05-02-2012, 09:27 PM
Each script must be independent of the other in totality, name wise. I didn't study your code, but this problem arises when you are trying to duplicate a server-side codeset on the same page. I see above everything looks different, but with accompanying hidden scripts is there something being used on both? In either case, I'd go back into that query link from above. The guys that answered her question will still get notified of an additional post in their email, and can probably give you the fast-track answer.

Barry McMahon
05-02-2012, 09:51 PM
thanks I'll try that!

05-03-2012, 02:28 PM
Both links are going to Vote.php. Why would it increment separately?

Barry McMahon
05-03-2012, 09:00 PM
I am trying to use the button link funtion in html to go to the page and at the same time increment the separate counters. Apparently I am missing something so brain dead simple that it barely seems possible for me to haver missed it. Can you clarify this for me based on the info I gave here or is there a better way?

I realize this is a very basic question but my needs are simple.