When passing a variable to another page via PHP I found that trying to find a solution to be above and beyond a pain as it is all over the place to find the relevant information regarding it such as how to send both single and multiple variables and how to select specific variables inside of a url and the security risks involved with url injections.
So far this is what I've managed to piece together.
Simple question:
Passing Variables from one page to another via URL-Bar
// PHP (Server side)
// To send it
header(Location: www.example.com?VariableId=$Var)
// To get it
$_GET["VariableId"]
// Sending multiple variables
header(Location: www.example.com?VariableId1=$Var1&VariableId2=$Var2)
// To get a variable in a multiple variable url it's the same method
// just specify a different variable
$_GET["VariableId1"]
$_GET["VariableId2"]
However I have had difficulty understanding how to do something similar to the PHP in javascript (Client side), how to get a specific variable from the URL to use on the page.
To redirect in javascript like in PHP see link as it's the best one I've found. How to redirect to another webpage in JavaScript/jQuery?
I assume you can put ?VariableId=Blarg at the end of the links referenced in the link to make it work the same.
For security reasons I understand that it's unwise to use the url to send across variables as they can be used in ways unintended. I've done research on how do urlencode however came to no understanding and an explanation of how to use it (both encoding it and decoding it would be greatly appreciated) and is urlencode protection enough?