Why am i getting Undefined index?

Hi,

I am quite surprised at this error:

Notice: Undefined index: delivery in /abc/abc/public_html/cow/application/controller/checkoutController.php on line 72

This is the code:


    public function shippingAction(){
        $cart = new Cart();
        $country = $delivery->selectAllByCountry();
        
        if(isset($_POST['delivery']) || count($_POST['delivery']) > 0){
        $cart->addDeliveryAndPromotionAndTotal();
        header('location: '.__SITE_PATH.'checkout/summary');
        }
        
        include('../application/view/html/checkout/shipping.php');
    }

And then in the front end i have the following:


                <ul>
                    <?$j=0;?>
                    <?while($row = mysql_fetch_array($country)):?>
                        <li>
                            <input type="radio" style="float:left;" name="delivery" id="<?=$row['ID']?>" value="<?=$row['ID']?>" <?= $j == 0 ? 'checked="checked"' : '' ?>/>
                            <label style="width:auto; float:left;" for="<?=$row['ID']?>">
                                <?=$row['name']?>
                                &pound;<?=number_format($row['price'],2)?>
                            </label>
                            <div class="clear"></div>
                        </li>
                    <?$j++;
                    endwhile;?>
                </ul>

Any ideas why i get the error?

Thanks

That or needs to an and.

What your code says right now is if index delivery doesn’t exists count index delivery. When it should say if index delivery doesn’t exists fail.

Thanks,

I have changed it to:


if(isset($_POST['delivery']) && count($_POST['delivery']) > 0){

And it now works…

Thanks again