I have been searching for hours and can't seem to locate information on something that I feel should be pretty simple.
I want to click on a hyperlink and set a session variable.
I've found examples on how to pass variables between pages but not within the same page.
I would prefer not to pass the variables via the URL because I want to keep the URL clean. I also gather that it is better coding practice to use session variables.
I dont want to pass the variables using a form whereby the user populates a textbox. Instead, I want the variables embedded within the url.
Here's an example of what I'm trying to achieve:
##########################
<?php
session_start();
?>
<body id="twoColLayout" class="<?php echo $_SESSION['submenu']; ?>">
<form action="index.php" method="POST">
<a href="index.php?submenu="search_bookmark">Search bookmarks</a>
</form>
##########################
Objective - When I select the link, the page reload with the variable 'submenu' set to 'search_bookmark'.
This then sets the class within the <body> tag. This is used for a CSS style sheet.
Can anyone please provide a helping hand. Or alternatively suggest a better way of doing this. To be honest I'm a PHP beginner.
thanks and regards.