How to get JavaScript variable value in PHP

You will need to use JS to send the URL back with a variable in it such as:
http://www.site.com/index.php?uid=1

by using something like this in JS:

window.location.href=ā€¯index.php?uid=1";

Then in the PHP code use $_GET:

$somevar = $_GET["uid"]; //puts the uid varialbe into $somevar

Leave a Comment