I have the following code and everytime I try to echo something above my include it doesn't work, seems like the 'include' is breakng my code.
PD:For more information my file is inside /my_main_folder/administrator/components/com_helloworld/
<?php
define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../../' ));
include(JPATH_BASE.'/libraries/loader.php');
$name = "a";
$username = "b";
$password = "jhvv";
$email = "arcghh";
addJoomlaUser($name, $username, $password, $email);
function addJoomlaUser($name, $username, $password, $email) {
jimport('joomla.user.helper');
$data = array(
"name"=>$name,
"username"=>$username,
"password"=>$password,
"password2"=>$password,
"email"=>$email,
"block"=>0,
"groups"=>array("1","2")
);
$user = new JUser;
//Write to database
if(!$user->bind($data)) {
throw new Exception("Could not bind data. Error: " . $user->getError());
}
if (!$user->save()) {
throw new Exception("Could not save user. Error: " . $user->getError());
}
return $user->id;
}
?>