In both cases you will need a form in your HTML code.
An example, utilizing the "hidden input" to send the variable.
<form name="MyGang">
<input name="secret_society" type="hidden" value="empty" />
</form>
You would basically need to define the value of that form:
var x = document.URL;
document.MyGang.secret_society.value = x;
Then use post/get in PHP to get the variable, e.g.:
$_GET['secret_society']
The "alternative" (using XhttpRequest) is basically the same; the difference being that the variable is sent to PHP instantly instead of waiting to press the "submit" button.
See http://www.w3schools.com/php/php_ajax_intro.asp for details.