I have the following code that enables the user to upload a file. This gets written into a SQL database and I then want the page to redirect
. Can anyone tell me why it is not redirecting? It completes the other lines fine.
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
Choose your file:
<input name="csv" type="file" id="csv"/>
<input type="submit" name="Submit" value="Submit" class="button"/>
</form>
<?php
$connect = mysql_connect("localhost",username,password);
mysql_select_db($database,$connect);
if ($_FILES[csv][size] > 0)
{
$file = $_FILES[csv][tmp_name];
$handle = fopen($file,"r");
while ($data = fgetcsv($handle,1000,",","'"))
{
if ($data[0])
{
$insert_query = "REPLACE INTO `tableNames` SET
`schoolName` = '".$schoolname."',
`teacherName` = '".$data[0]."'
;";
$result = mysql_query($insert_query);
}
}
}
header("Location: https://redirecting address/");
?>
UPDATE
This worked:
....
$result = mysql_query($insert_query);
}
}
}
echo("<script>location.href = 'http"//redirect address';</script>");
?>