I have one question which is somewhat two-parted (though the parts go hand in hand). I’ve started picking up PHP, and I wanted to do two things when an image is clicked.
I want the click to
- Increment a session variables, say
$_SESSION['entry']. - Reload the current page (say
index.php).
How should I go about this?
To be clear, I’m not asking for someone to code this for me, I’d just like to be pointed in the right direction because I’m not too sure what the best way would be.
Well, anchor links “reload” the page if the
hrefpoints to the same page. So, all you need to do is tell PHP you want to increment the session variable. You could use a GET variable to do this:And then in your
index.php:This assumes you’ve already initialized the session variable
counterat some point. You can check out the wonderful PHP docs to explain the functions used above if you aren’t familiar with them.