In the following code (which is from the pastebin link above):
foreach($form_data as $name=>$value)
{
mysqli_query($db, "UPDATE $mysql_table SET $name='".mysqli_real_escape_string($db, $value)."' WHERE ID=$id") or die('Failed to update table!<br>'.mysqli_error($db));
}
mysqli_close();
header('Location: '.$success_url);
exit;
You need to put the connection or link handle generated during the connection in the mysqli_close() statement so it knows which one to close (i.e. you can have more than one open at a time). If you change your snippet to use the following line the close error should go away.
mysqli_close($db);
Once the close error goes away then the redirect header issues on the next line may work. I say may because if you have other output happening before you issue the header it will continue to fail. Headers can only be used successfully when the web page has not generated any other non-header output.
As a side note you may want to build one large SQL string instead of doing a database update for each field returned. However, that's food for some more learning and/or a future question.