Losing value of POST fields when user connection is slow

0

I have a problem when users update the site and in the middle of the action the connection slows down or crashes and comes back quickly at the time of the process.

Sometimes the user only updates the title of a news article, for example, but at the time of saving, the save.php file that does the UPDATE in mysql for some reason loses the values that should be in the _POST of all fields and save all in white over what was, because the table ID comes via GET (and this value does not lose as it is in the URL).

This usually occurs when the user connection becomes unstable during the process. Is there any way to validate and / or prevent data loss?

Here's an example:

<?
$idBanner   = $_GET["id"];
$Titulo     = $_POST['Titulo'];
$Resumo     = $_POST['Resumo'];

$consulta="UPDATE site_banner SET Titulo='$Titulo', Resumo='$Resumo' WHERE idBanner = '$idBanner' ";
$con=mysql_query($consulta,$db) or die(mysql_error());

echo "<meta http-equiv='refresh' content='0;URL=banner.php'>";
?>
    
asked by anonymous 08.11.2018 / 13:21

1 answer

0

Take the test in the post before putting it in the bank:

if (!empty($_POST)) {
    // coloque seu codigo aqui;
}
else {
    // devolva para o usuário uma mensagem ou retorne para o form;
}

Greetings

    
08.11.2018 / 13:41