Whenever I try to login a prompt opens asking for the basic permissions, after that its being redirected to my redirect_uri with an URL
=\">http://loc
Change this
$loginUrl = $facebook->getLoginUrl(array ( 'display' => 'popup', 'redirect_uri' => 'http://localhost/demo' ));
to
$loginUrl = $facebook->getLoginUrl(array ( 'display' => 'popup', 'redirect_uri' => 'http://localhost/demo/index.php' ));
And see if this works !!