![]() |
|
|
|||||||
| For more information about the ads and why they're here, please see the FAQ |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Pass down the name of the file you want
And the users id that is in the sql table csv layout Name, Email Hope it helps ya all. Code:
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'roundcubemail';
mysql_select_db($dbname, $conn);
echo mysql_errno($conn) . ": " . mysql_error($conn). "\n";
///Fin connection
$user_id = $_GET['user_id'];
$file = $_GET['file'];
if($user_id == "" || $file == "")
{
echo "You have no user id $user_id<br>OR files";
}
if($user_id != "" || $file != "")
{
echo $user_id;
echo "<br>$file";
$row = 1;
$handle = fopen($file, "r");
echo "$handle";
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
echo "<br />";
$row++;
$name = $data[0];
$email = $data[1];
echo "<b>Name: </b>" . $name. "\n";
echo "<B>Email:</B> " . $email . "\n";
$query = "INSERT INTO `contacts` ( `contact_id` , `user_id` , `changed` , `del` , `name` , `email` , `firstname` , `surname` , `vcard` ) VALUES ( '', '$user_id', '1985-09-15 00:00:00', '0', '$name', '$email', '', '', '' );";
echo "<br>";
mysql_query($query, $conn);
echo mysql_errno($conn) . ": " . mysql_error($conn) . "\n";
}
fclose($handle);
}
?>
|
|
#2
|
|||
|
|||
|
Can you give me a sample of the csv file? Don't wanna crash the db
![]() Thanks! |
|
#3
|
|||
|
|||
|
csv layout
Name, Email |
|
#4
|
|||
|
|||
|
May seem like a stupid question, but where exactly (in which lines) do I insert username and file?
|
|
#5
|
|||
|
|||
|
well you will have on your webserver the csv file then you will have
http://yourwebsite.com/cvsupload.php...file=FILE_NAME |
|
#6
|
|||
|
|||
|
link doesn't work :P just quote an exact sample of a csv file you would recommend! only 3 lines...
thanks anyway.... |
|
#7
|
|||
|
|||
|
Create a directory on your server called cvsupload.php upload the cvs file to your server format is bob,boobs@boobs.com chris noen,namit@something.org create a file called cvsupload.php in the direcotry csv-upload. find in the sql tables the userid within the roundcube tables then replaec that iin the link below. replace yourwebsite.com with your website http://yourwebsite.com/cvsupload.php...file=FILE_NAME |
|
#8
|
|||
|
|||
|
That didn't work.
Code:
0: user_id (my emailaddress) file.csvResource id #3 Name: Name Name Email: email 0: Name: Name Name Email: email 0: |
|
#9
|
|||
|
|||
|
same like me! the script only imports the first 3 contacts and then it stops...
Code:
0: 1 contacts.csvResource id #3 Name: ïûÿBerlin - Michael Email: michael@berlin.de 0: Name: Dublin - Billy Email: billy@dublin.com 0: Name: Dublin - William Email: william@dublin.com The output log seems ok, so what else can that be? |
|
#10
|
|||
|
|||
|
Can you check the sql tables and see if the are being entered?
You also have to logout and then login to roundcube. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
| For more information about the ads and why they're here, please see the FAQ |