PHP and Javascript Variables

Is there any way to transfer variables from javascript to php?

I don’t know PHP but it is serverside and JavaScript is a client side. So its not possible to have them communicate because the php code is executed before it is sent to the client.

The only way to get the javascript variable to php is to send it in the url.

yourpage.php?yourJSvar=1

Like I said though, I don’t know php so there may be some crazy way but I don’t think there is.

Hope that helps, khamstra

Well in that case, does anyone know a script in php that gets the site the viewer came from. I know how to do it in Javascript,

document.referrer()

But I’m not sure how to do it in php.

I’m can’t remember but it’s either $_SERVER[‘HTTP_FROM’]; or $_SERVER[‘FORWARDED’];

But you can transfer variables from php to javascript acutally… as simple as
<?php echo ‘<script type=“text/javascript”> var1 = foo; </script>’; ?>
like writing js with php :wink: