how to unset a post variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kushaljutta
Forum Commoner
Posts: 50
Joined: Fri Dec 26, 2008 11:05 am

how to unset a post variable

Post by kushaljutta »

i want to destroy a $_POST['some variable'] in my code..

i used unset(); function for that but it is not working....

my problems is

first of all i sent a variable(some x in sample.php) to next page(xyz.php) in that page i need that variable($x) for inserting a data..after inserting i press F5 it is again inserted into the database..

so i want to unset that variable($x) in xyz.php page....

can anybody help me in that case..

and also i need to block page refreshing script
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Re: how to unset a post variable

Post by Burrito »

every time you refresh the page, the $_POST array will repopulate. The best solution to your issue is to redirect back to the page using header() or some other redirection method so the $_POST array gets dumped.

look how phpBB does it when you post a message. It takes you to a page (where data is posted) then redirects you back to the thread....
Post Reply