试图避免使用PHP重新提交表单

I am trying to avoid re-submission of some items from a form I have by doing the following:

if(isset($_REQUEST['command']) && $_REQUEST['command']=='add' && $_REQUEST['itemId']>0)
{
    if (array_key_exists($pid, $_SESSION['cart']['itemId']))
    { 
    }
    else 
    {
        $pid=$_REQUEST['itemId'];
        addtocart($pid,1);
        $itemAdded = 1;
        $max = 0; 
foreach ($_SESSION['cart'] as $item) 
    { 
        $max = $max + $item['qty']; 
    }
    }
header("Location: http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]);
exit();
}

However, I keep getting "This webpage has a redirect loop". The thing is that I want my site to come back to the same website but not to get into the If anymore.

Any ideas?

Use unset($_POST); or just redirect to another page after submitting. This is how it's done on most websites.