when i click upload button, it takes long to load wthout csv, but when i upload csv it dispays csv pocessed..but there is no data uploaded...what could be the wrong with my code?...please assist me
<form enctype="multipart/form-data" method="POST" action="" >
<input type="file" name="file" /><br />
<input type="submit" value="upload csv" name="submit"/>
</form>
<?php
$connection = mysql_connect("localhost","root","")
or die ("Couldn't connect to server");
$db = mysql_select_db("syrecuse1", $connection)
or die ("Couldn't select database");
if(isset($_POST['submit']))
{
$file = $_FILES['file']['tmp_name'];
$handle = fopen($file,"r");
$processed = false;
while(($fileop = fgetcsv($handle,1000,",")) !== FALSE)
{
$firstname = $fileop[0];
$lastname = $fileop[1];
$email = $fileop[2];
$sql = mysql_query("INSERT INTO test (first_name, last_name, email) values('$firstname', '$lastname', '$email')");
$processed = true;
}
if($processed)
{
echo "CSV was processed.";
}
else
{
echo "CSV was not processed.";
}
}
else
{
echo "Submission was not found.";
}
?>