Jump to content

Recommended Posts

Test:

[code]

<?php

$_POST['one'] = "This is a post included:";
$_POST['two'] = "- post two";
$_POST['three'] = "- post three";

if($_POST == true)
{
  foreach($_POST as $value){
    echo $value." ";
  }
  echo "<br />";
}


$_POST['two'] = false;

if($_POST == true)
{
  foreach($_POST as $value){
    echo $value." ";
  }
  echo "<br />";
}


$_POST = false;


if($_POST == true)
{
  foreach($_POST as $value){
    echo $value." ";
  }
}
else
{
  echo "No post is set";
}

?>

[/code]

Outputs:
[quote]

This is a post included: - post two - post three
This is a post included: - post three
No post is set

[/quote]
Link to comment
https://forums.phpfreaks.com/topic/31563-how-to-unset-_post/#findComment-146344
Share on other sites

[quote author=taith link=topic=119602.msg490111#msg490111 date=1166784908]
$_POST[] vars are [u]read only[/u] you cant activly create/change/alter/delete these vars other then by a form, or by changing to a different page.
[/quote]

You can unset() them though.  Try running this piece of code and seeing how many times it echo's what you type in the field:

[code]<form method="POST">
<input type="text" name="vartest">
<input type="submit" name="submit">
</form>

<?php
echo $_POST['vartest'];
unset($_POST['vartest']);
echo $_POST['vartest'];
?>[/code]

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/31563-how-to-unset-_post/#findComment-146345
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.