<?php require_once('Connections/taconvidado.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
$target_path = 'D:';
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$_FILES['uploadedfile']['tmp_name'];
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "O arquivo ". basename( $_FILES['uploadedfile']['name']).
" foi importado corretamente <br><br>";
$fp = fopen('D:\planilha.csv', 'r');
$inseridos = 0;
while($dados = fgets($fp)){
$registros = explode(';',$dados);
$sql_insert = "INSERT INTO news (nome, email, telefone) VALUES('" . $registros[0] . "', '" . $registros[1] . "', '" . $registros[2] . "')";
print($dados."<br>");
if(mysql_query($sql_insert)){
$inseridos++;
} else {
print "Impossível inserir no banco de dados. Erro: " . mysql_error()."<br>";
}
}
} else{
echo "Erro ao importar o arquivo, tente novamente!!!";
}
echo "<br> Foram inseridos " . $inseridos . " novo cadastros <br>";
?>
</body>
</html>vamos nos ajudando ehehehe... abraços



Postagens
Não informado
