[thelist] deleting php vars

Simon Perry simon.perry at si-designs.co.uk
Thu Oct 30 08:29:38 CST 2003


----- Original Message ----- 
From: "jan guichelaar [artmiks]"
> Hello all,
>
> I have a quostion about php.
> I made a cms with php and mySQL.
> With a form i post/get some vars to a php-page. In this page i put the
> posted vars into de dbase.
> Now my problem is, when people press the 'refresh' button on their
browser,
> the php-page puts the vars again into the dbase.
>
> Is it possible for php to 'forget' the vars it gets from the previous page
> through a post/get  method?
>
Jan,

Depends on your page flow but the trick I usually use is to reload the page
after a successful insertion, sending first a [1] HTTP 205 header and then
the page location without any appended vars (or at least only the ones you
still want). If you are using sessions remember to unset() and
session_unregister() any posted vars that may have been saved.

if ($dbInsert=="insert went ok"){
    header("Status:  205 Reset Content");
    header("Location: original-page.php");
}

Simon

[1] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html



More information about the thelist mailing list