2
nevermind the code from here works
http://dev.xoops.org/modules/xfmod/project/showfiles.php?group_id=1061&release_id=786&dl=2160 import_users.php
// christian@frxoops.org - http://www.frxoops.org
// Import users from a csv file into xoops 2.0.x
// 26 january 2006 : add trim() for encrypt password
// variables
$bdd= "x20132";
$host= "localhost";
$user= "root";
$pass= "";
$fichier = "users.csv"; // data file as : first name(pseudo);last name;email;password
// remove line break on last record
mysql_connect($host,$user,$pass) or die("Unable to connect Database");
mysql_select_db($bdd);
// Open file for read
if (file_exists($fichier))
$fp = fopen("$fichier", "r");
else{ // unknown file
echo "File not found !Import stopped.";
exit();
}
echo 'Begin file import '.$fichier.'';
// import line by line
while (!feof($fp)){
$ligne = fgets($fp,4096);
$liste = explode(";",$ligne); // create array
$user = $liste[0]; //first field
$name = $liste[1]; //second field
$email= $liste[2];
$pass= md5(trim($liste[3]));
// Add user in xoops_users table
$query = "insert into xoops_users (uname, name, email, pass) VALUES ('$user', '$name','$email','$pass')";
$result= mysql_query($query);
$uid = mysql_insert_id();
//Add user in group : users registered
$numgroup ='2';
$query = "INSERT INTO xoops_groups_users_link (groupid, uid) VALUES('$numgroup', '$uid')";
$result= mysql_query($query);
if (mysql_error()){
echo "Error in database : ".mysql_error();
echo "Importation stoppée.";
fclose($fp);
exit();
}else{
echo "Record ".$uid." - ".$user." added ";
}
}
echo "Import finished successfully.";
fclose($fp);
users.csv
Bill;Barra;bill.barra@yahoo.com;245AVB
Mark;Knopfler;mark@knopfler.com;AVB245
Jim;Morrison;jim.morrison@gmail.com;bngh123
Roger;Daltrey;roger@daltrey.com;XXD23
edit db prefix and it works although it can be improved with adding other field such as user_regdate