Why am i getting Undefined index?


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){
        header('location: '.__SITE_PATH.'checkout/summary');

And then in the front end i have the following:

                    <?while($row = mysql_fetch_array($country)):?>
                            <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']?>">
                            <div class="clear"></div>

Any ideas why i get the error?


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.


I have changed it to:

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

And it now works…

Thanks again