Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Notice: Undefined index: chkItems on line 4 (php)

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #164728
    Attila Hajzer
    Participant
    <input type="checkbox" name="chkItems[]" value="120">Mask<br> 
    <input type="checkbox" name="chkItems[]" value="120">Assault Vest<br>  
    <input type="checkbox" name="chkItems[]" value="300">Combat Pistol<br>  
    <input type="checkbox" name="chkItems[]" value="80">Paintball Hopper<br> 
    <input type="checkbox" name="chkItems[]" value="75">Case of 2000 Paintballs
    
    
    
    <?php
    
    # set variables 
    $items = $_GET["chkItems"];
    $message = "";
    
    if(isset($_GET["chkItems"]))
    {
    
        foreach ($items as $i)
        {
            echo $i. "<br />";
        }
    
    }else{
    
        $message .= "<b>Error</b>: No items were selected.";
    
    }
    
    ?>
    

    Before performing any calculations ensure on the server-side that at least one item was checked. If no items were selected, output an error message; otherwise, you can begin the totaling and output process.

    I get this error: Notice: Undefined index: chkItems in C:\xampp\htdocs\PHPCookiesPractice\serverCode\calcTotal.php on line 4

    and only if none of the checkboxes are checked.

Viewing 1 post (of 1 total)
  • The forum ‘Back End’ is closed to new topics and replies.