Asim Zaidi
Asim Zaidi

Reputation: 28324

how to get info from drupal database

I am new to drupal and I want to see the logged in user name and his email address in a phpscript which is not in drupal installation. Any idea how would I go about it. Using drupal 6.2

tried this already

<?php
require_once 'includes/bootstrap.inc';
require_once 'includes/common.inc';
require_once 'includes/module.inc';

global $user; 
if ($user->uid) 
{ 
$name=$user->name; 
echo $name; 
}

?>

Thanks

Upvotes: 2

Views: 248

Answers (1)

EMI
EMI

Reputation: 826

The best way to do this is hook your standalone script into Drupal's bootstrapping mechanism. Here's a SO question that shows how to do that.

Then, your global $user solution will work.

Upvotes: 4

Related Questions