It is first time to create a smart uploader that uploads and validates also. Here I have included my code for trying to call a procedure whilst submitting the csv file thru a form, php doesn't complete my code and doesn't show any errors. Code goes as follows. Your help is highly appreciated. Thank you
<?php
error_reporting(-1);
error_reporting(E_ERROR | E_PARSE);
ini_set('max_execution_time',0);
ini_set('upload_max_filesize', '50M');
ini_set('post_max_size', '50M');
ini_set('max_input_time', 0);
ini_set("memory_limit", "-1");
set_time_limit(0);
$ip = getenv('REMOTE_ADDR');
$conn=mysqli_connect("localhost","root","password") or die("Could not connect");
mysqli_select_db($conn,"db") or die("could not connect database");
$procedure="
drop procedure if exists dV;
DELIMITER $$
CREATE PROCEDURE dV(IN td, ts, cd, pc, lt, nt, xp, fn, sn, ds, pp, uploadedby, op, month, year)
BEGIN
INSERT INTO temp(`td`, `ts`, `cd`, `pc`, `lt`, `nt`, `xp`, `fn`, `sn`, `ds`, `pp`, `uploadedby`, `op`, `month`, `year`) VALUES
('$td','$ts','$cd','$pc','$lt','$nt','$xp', '$fn', '$sn', '$ds', '$pp', '$ip', '$op', '$month', '$year');
update anew set xp = true where length(lt) < 6;
END$$
DELIMITER ;
";
if(isset($_POST["submit_file"]))
{
$op= $_POST['op'];
$month = $_POST['month'];
$year = $_POST['year'];
$file = $_FILES["file"]["tmp_name"];
$file_open = fopen($file,"r");
while(($csv = fgetcsv($file_open,1000, ",")) !== false)
{
$ct= $csv[0];
$ts = $csv[1];
$cd= $csv[2];
$pc = $csv[3];
$lt= $csv[4];
$nt= $csv[5];
$xp = $csv[6];
$firstname = $csv[7];
$surname = $csv[8];
$ds= $csv[9];
$pp= $csv[10];
if(mysqli_query($connect, "DROP PROCEDURE IF EXISTS dV"))
{
if(mysqli_query($connect, $procedure))
{
$query = "CALL dV('".$ct."', '".$ts."', '".$cd."', '".$pc."', '".$lt."', '".$nt."', '".$xp."', '".$firstname."', '".$surname."', '".$ds."', '".$pp."', '".$uploadedby."', '".$op."', '".$month."', '".$year."')";
mysqli_query($connect, $query);
echo "<script type=\"text/javascript\">
alert(\"File uploaded successfully\");
window.location.href = '/insights/datauploader/';
</script>";
}
else
{
echo"<script type=\"text/javascript\">
alert(\"There is some error. Please try again.\");
window.location.href = '/insights/datauploader/';
</script>";
}
}
}
}
?>