what up all?
quickie... I know I can empty all session vars but lets say I have a form with 500 fields on it. I keep the value of those fields in case of errors. If the user submits a good record I want to clear that form so they can enter their next record.
Is there a way to empty all POST vars at once?
like session_unset() ???
Can you unset POST VARS?
Moderator: General Moderators
until now it's an array like any other (except beeing auto-global).
So the following might not be sophisticated or good style but it's workingBut the question remains: Why? What is its purpose? 
So the following might not be sophisticated or good style but it's working
Code: Select all
<html><body><?php
if(count($_POST) > 0)
{
echo '<pre>'; print_r($_POST); echo '</pre>';
$_POST = array();
echo '<pre>'; print_r($_POST); echo '</pre>';
}
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="submit" /><br />
<?php for($i=65; $i!=91; $i++) { ?>
<input tpye="text" name="<?php echo chr($i); ?>" value="<?php echo chr($i+32); ?>" />
<?php } ?>
</form>
</body></html>clearing out because you have something likewithin your script?
Code: Select all
<input type="text" name="amount[order1]" value="<?php if (isset($_POST['amount']['order1'])) echo (int)$_POST['amount']['order1']; ?>" />I tried to do a loop to unset all active session variables, and it killed my php.exe.JPlush76 wrote:what is the purpose of unseting the post vars?
so it clears out the fields for the next order.
I was leary about doing loops to unset all the POST vars. I was hoping there was a nice magic php function I was missing