I\'m trying to run a quick php script when users leave my website, and also pass a variable from my javascript to php but i\'m not quite sure how to include the php file and
Try an ajax request. Depending on your php script you will need $.post or $.get
$.post
$.get
jQuery:
EDIT:
Your php script should reference the $_POST array if you use my code above.
$_POST