Losing value of POST fields when user connection is slow

Asked

Viewed 31 times

0

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

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

This usually occurs when the user’s connection becomes unstable during the process. Is there any way to validate and/or prevent this data from being lost?

Following 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'>";
?>

1 answer

0

Take the test in the post before you put 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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.