# export user details from database via cron

Is there any way I can export user details from joomla database such as name, password, email address, and import them into owncloud database via a cronjob?

• Have a look in the ROOT/cli directory where you will find a couple of scripts that you base base your own script on. – Lodder Aug 17 '16 at 17:47
• hi, thanks for the reply, I'll take a look but first i need to identify whether its possible, someone told me the owncloud and joomla encoding algorithm for password generation is different – user2513528 Aug 17 '16 at 17:51
• I don't know about owncloud, so perhaps it may be easier for you to create a simple PHP file with 1 single variable <?php $foo = 'bar'; ?> and then try to push this value to the database. – Lodder Aug 17 '16 at 17:54 ## 1 Answer There might be others, more elegant ways to do it but I did it pretty simple - I created a non-Joomla PHP file, which connects to Joomla's DB and dumps user table into a CSV file. I then scheduled to open this page with CRON. Notice the headers for pushing the file as a download are commented out, so the file will be created and saved in the same directory with your PHP file. <?php // Database Connection$host="localhost";
$uname="dbuser";$pass="dbP@";
$database = "joomla_db";$connection=mysql_connect($host,$uname,$pass); echo mysql_error(); //or die("Database Connection Failed");$selectdb=mysql_select_db($database) or die("Database could not be selected");$result=mysql_select_db($database) or die("database cannot be selected <br>");$output = "";
$table = "ab7cd_users"; // Enter Your Table Name$sql = mysql_query("select id,name,username,email,block from $table");$columns_total = mysql_num_fields($sql); // Get The Field Name for ($i = 0; $i <$columns_total; $i++) {$heading = mysql_field_name($sql,$i);
$output .=$heading."\t";
}
$output = substr($output, 0, -1);
$output .="\r\n"; // Get Records from the table while ($row = mysql_fetch_array($sql)) { for ($i = 0; $i <$columns_total; $i++) {$output .=$row["$i"]."\t";
}
$output = substr($output, 0, -1);
$output .="\r\n"; } // Download the file$filename = "users.csv";
/*
header('Content-Disposition: attachment; filename='.$filename); echo$output;
file_put_contents ($filename ,$output);