hi, i have an import csv script but it does not get entered into the database. only "uploaded successfully" and the data is echoed but nothing in the database is something wrong with it? and is it sql injection safe?
<?php
if(isset($_SESSION['sess_user_id']))
{
if (isset($_POST['ubmit'])) {
require "connection.php";
$session = $_SESSION['sess_user_id'];
if (is_uploaded_file($_FILES['csv']['tmp_name'])) {
echo "<h1>" . "File ". $_FILES['csv']['name'] ." uploaded successfully." . "</h1>";
echo "<h2>Displaying contents:</h2>";
readfile($_FILES['csv']['tmp_name']);
}
//Import uploaded file to Database
$handle = fopen($_FILES['csv']['tmp_name'], "r");
$import=$dbh->prepare("INSERT INTO contact1(
user_id,
salutation,
fname,
lname,
dob,
house,
mobile,
office,
email,
spouse_name) VALUES(?,?,?,?,?,?,?,?,?,?");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$import->execute($data);
}
fclose($handle);
}
}
?>
TIA!