Fairly new to both php and Drupal. I have searched for this answer, and have found the one everyone keeps repeating, but I cannot get it to work.
What I've done, is create a form that accesses an 'external' php file, located in the root folder. (I have a lot of trouble wrapping my head around modules, so for me, this was an easier path). Within this php file, I am attempting to grab the uid of the current user to be stored in a table.
The solution I've found is to load bootstrap.inc, but I've failed miserably every time. The one thing I thought might have been the issue, is that I have loaded Drupal 7 into a sub-domain.
I'm obviously not changing the correct element, so e.g. lets say my domain is http://apples.fruitrocks.com. What do I change below, to get this to work?
define('DRUPAL_ROOT', '/var/www/vhosts/mysite.com/httpdocs/');
$_SERVER['HTTP_HOST'] = 'mysite.com';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);