6
Here is a script I modified to upload users in the form:
FirstName, LastName, email, password
Note, that I will be communicating to my users that they need to access the "Lost my Password" link and resent their password to something other than what I generated.
Note you have to change the variables $bdd, $host, $user and $pass in the first section (I made these values into variables from the original script).
Good luck.
Kurt
// christian@frxoops.org - http://www.frxoops.org
// Import users from a csv file into XOOPS 2.0.x
// variables
$bdd= "test";
$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($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);