选择两个选项显示错误

I have a form in php to select 3 choices , when i select all three no error is shown, but when i select two choices it shows error but choice is saved in data base, and shows record saved, but also show Notice: Undefined index: hb3 in C:\wamp\www\uni1\admin\courses.php on line 14 07/25/2014

<?php 
include('auth.php');
include('conect.php'); $msg='';
if(isset($_POST['save']))
{
$category = $_POST['category'];
$cname = $_POST['cname'];   
$code = $_POST['code']; 
$type = $_POST['type'];
$dur = $_POST['dur'];
$fee = $_POST['fee'];                                                                                 
$hb1 = $_POST['hb1'];
$hb2 = $_POST['hb2'];
$hb3 = $_POST['hb3'];   
$catid =mysql_insert_id();
$sql = mysql_query("select * from category where catid='$category'");// to get  category code from category table
$rs = mysql_fetch_array($sql);
mysql_query("INSERT INTO courses1 (catid,cname, code, type, dur, fee, hb1, hb2, hb3) 
VALUES ('$category','$cname','$code','$type','$dur','$fee','$hb1','$hb2','$hb3')");
$msg = '<h3>Record Saved</h3>'; 
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>courses</title>
<link rel="stylesheet" type="text/css" href="headerstyle.css" />
</head>

<body>
07/25/2014
<div class="fixx"><?php include('header.php');?></div>
<div class="tabl">
<table width="700" border="0">

  <tr>
    <td>
    <form method="post" action="courses.php">
    <table width="700" border="1" cellpadding="10">
      <tr>
        <td colspan="2"><h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ADD COURSES &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="courses_list.php"> EDIT</a> </h3></td>
        </tr>
      <tr>
        <td colspan="2"><?php echo $msg;?></td>
        </tr>
      <tr>
      <td width="174"><h4>Select Category </h4></td>
        <td width="674"><label for="category"></label>
          <select name="category" id="category">
          <?php $qre = mysql_query("select * from category ORDER BY name");
          while($res = mysql_fetch_array($qre))
          {
            echo '<option value="'.$res['catid'].'">'.$res['name'].'</option>';  


            }



          ?>


          </select>          </td>
      </tr>
      <tr>
        <td width="174"><h4>Enter Course Name</h4></td>
        <td width="674"><label for="cname"></label>
          <input name="cname" type="text" id="cname" size="70" /></td>
      </tr>
      <tr>
        <td><h4>Course Code</h4></td>
        <td><input type="text" name="code" id="code" /></td>
      </tr>
      <tr>
        <td><h4>Type</h4></td>
        <td><label for="type"></label>
          <select name="type" id="type">
            <option value="Month"><h4>Month</h4></option>
            <option value="Semester"><h4>Semester</h4></option>
            <option value="Year"><h4>Year</h4></option>
          </select></td>
      </tr>
      <tr>
        <td><h4>Duration</h4></td>
        <td><p>
          <select name="dur" id="dur">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
          </select>
        </p></td>
      </tr>
      <tr>
        <td><h4>Fee</h4></td>
        <td><input type="text" name="fee" id="fee" /></td>
      </tr>
      <tr>
        <td><h4>Mode</h4></td>
        <td><h4>Online
          <input type="checkbox" name="hb1" id="hb1" value="online" /></h4><br />
          <h4>Private
          <input type="checkbox" name="hb2" id="hb2" value="private" /></h4>
          <br />
          <h4>Regular
          <input type="checkbox" name="hb3" id="hb3" value="regular" />
</h4>          <br />
          </label></td>
      </tr>
      <tr>

        <td><input type="submit" name="save" id="save" value="Submit" /></td>
      </tr></h2>
    </table>
    </form>
    </td>
  </tr>

</table>
</div>

</body>
</html>

Please solve my problem

use hidden filed

<input type="hidden" id="hb1_" name="hb1"  value="-1">
<input type="checkbox" id="hb1" name="hb1" value="online" />

<input type="hidden" id="hb2_" name="hb2"  value="-1">
<input type="checkbox" id="hb2" name="hb2" value="private" />

<input type="hidden" id="hb3_" name="hb3"  value="-1">
<input type="checkbox" id="hb3" name="hb3" value="regular" />

When checkox in not checked, then $_POST doesn't contain given key, so you cannot assign its value. Whenever you use checkbox, assign given post value like this:

$hb3 = isset($_POST['hb3'])?$_POST['hb3']:'';

then in case of undefined value you will assign an empty string and you will not see those notices.

There is error because when you are selecting only two choices then third choice has null means no value

$hb3 has no value for choice

you should check is value set or not if not then assign some default values

$hb1 = isset($_POST['hb1'])?$_POST['hb1']:'';
$hb2 = isset($_POST['hb2'])?$_POST['hb2']:'';
$hb3 = isset($_POST['hb3'])?$_POST['hb3']:'';

You should do like that if don't want notice "Undefined index"

$hb1 = isset($_POST['hb1'])?$_POST['hb1']:'';
$hb2 = isset($_POST['hb2'])?$_POST['hb2']:'';
$hb3 = isset($_POST['hb3'])?$_POST['hb3']:'';