HELLO!! CAN ANY ONE GIVE ME SOME HELP ABOUT THIS RADIO BOX? IT WORK IF I SELECT IT, HOWEVER ONCE I LEAVE IN BLANK, IT DISPLAY AN ERROR MESSAGE. (Notice: Undefined index: discrate in C:\wamp\www\SSWP\renting.php on line 35 )

HI IS THE HTML CODE:

<div class="formorder">

  <form name="renting" method="post" action="renting.php">
    <table width="525" height="354">
      <tr>
        <td colspan="3"><div align="center" class="font_style">TRS VIDEO RENTAL SYSTEM - RENTING FORM</div></td>
      </tr>
      <tr>
        <td width="171">&nbsp;</td>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td height="28" class="font_style"><div align="right">Name:</div></td>
        <td colspan="2"><label>
          <input type="text" name="name" size="40" maxlength="40">
        </label></td>
        </tr>
      <tr>
        <td class="font_style"><div align="right">Address:</div></td>
        <td colspan="2"><label>
          <textarea name="address" cols="40" rows="4"> </textarea>
        </label></td>
      </tr>
      <tr>
        <td class="font_style"><div align="right">Email:</div></td>
        <td colspan="2"><label>
        <input name="email" type="text" size="40" maxlength="40">
   
        </label></td>
      </tr>
      <tr>
        <td class="font_style"><div align="right">Movie Type:</div></td>
        <td colspan="2"><label>
          <select name="movietype">
            <option selected ></option>
            <option>Sci-Fi</option>
            <option>Comedy</option>
            <option>Romance</option>
            <option>Suspence</option>
            <option>Horror</option>
          </select>
        </label></td>
      </tr>
      <tr>
        <td class="font_style"><div align="right">Date of Hire:</div></td>
        <td colspan="2"><label>
          <input name="dateofhire" type="text" size="40" maxlength="40">
        </label></td>
      </tr>
      <tr>
        <td class="font_style"><div align="right">Number of Days:</div></td>
        <td colspan="2"><label>
          <input name="numberofdays" type="text" size="40" maxlength="40">
        </label></td>
      </tr>
      <tr>
        <td class="font_style"><div align="right">Distcount Rate:</div></td>
        <td colspan="2"><label>
          <input type="radio" name="discrate" value="regular customer">
          Regular Customer
          <input type="radio" name="discrate" value="new customer">
          New Customer</label></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td width="47"><label>
          <input type="submit" name="btn" value="HIRE">
        </label></td>
        <td width="285"><label></label>
            <input type="reset"" name="reset" value="Reset"></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
      </tr>
    </table>
  </form>
  

</div>
<div class="body"></div>
</body>
</html>

HERE IS THE PHP CODE:

<?php


	
print"<P><strong>TR Video Rental System - CONFIRMATION</P></strong>"; 

echo "<div class='formorder'>";
echo "<table border=\"1\" width=\"420\">";
echo "<tr><td>";
echo "<p><b>NAME: </b>".$_POST['name']."</p>";

echo "</td></tr>"; 

echo "<tr><td>";
echo "<p><b>Address: </b>".$_POST['address']."</p>";
echo "</td></tr>";

echo "<tr><td>";
echo "<p><b>EMAIL: </b>".$_POST['email']."</p>";
echo "</td></tr>";

echo "<tr><td>";
echo "<p><b>Movie Type: </b>".$_POST['movietype']."</p>";
echo "</td></tr>";

echo "<tr><td>";
echo "<p><b>Date of Hire: </b>".$_POST['dateofhire']."</p>";
echo "</td></tr>";

echo "<tr><td>";
echo "<p><b>Number of Days: </b>".$_POST['numberofdays']."</p>";
echo "</td></tr>";

echo "<tr><td>";
echo "<p><b>Discount Rate: </b>".$_POST['discrate']."</p>";
echo "</td></tr>";	


?>

PLEASE HELP ME..... THANKS

JavaScript - code added.

<script type="text/javascript">
   function doit() {
      var t;
      if(renting.discrate[0].checked==false && renting.discrate[1].checked==false)
         return false;
     return true;
   }
</script>
<div class="formorder">

  <form name="renting" method="post" action="p1.htm" onsubmit="return doit()">
    <table width="525" height="354">
      <tr>
        <td colspan="3"><div align="center" class="font_style">TRS VIDEO RENTAL SYSTEM - RENTING FORM</div></td>
      </tr>
      <tr>
        <td width="171">&nbsp;</td>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td height="28" class="font_style"><div align="right">Name:</div></td>
        <td colspan="2"><label>
          <input type="text" name="name" size="40" maxlength="40">
        </label></td>
        </tr>
      <tr>
        <td class="font_style"><div align="right">Address:</div></td>
        <td colspan="2"><label>
          <textarea name="address" cols="40" rows="4"> </textarea>
        </label></td>
      </tr>
      <tr>
        <td class="font_style"><div align="right">Email:</div></td>
        <td colspan="2"><label>
        <input name="email" type="text" size="40" maxlength="40">
   
        </label></td>
      </tr>
      <tr>
        <td class="font_style"><div align="right">Movie Type:</div></td>
        <td colspan="2"><label>
          <select name="movietype">
            <option selected ></option>
            <option>Sci-Fi</option>
            <option>Comedy</option>
            <option>Romance</option>
            <option>Suspence</option>
            <option>Horror</option>
          </select>
        </label></td>
      </tr>
      <tr>
        <td class="font_style"><div align="right">Date of Hire:</div></td>
        <td colspan="2"><label>
          <input name="dateofhire" type="text" size="40" maxlength="40">
        </label></td>
      </tr>
      <tr>
        <td class="font_style"><div align="right">Number of Days:</div></td>
        <td colspan="2"><label>
          <input name="numberofdays" type="text" size="40" maxlength="40">
        </label></td>
      </tr>
      <tr>
        <td class="font_style"><div align="right">Distcount Rate:</div></td>
        <td colspan="2"><label>
                 <input type="radio" name="discrate"   value="regular customer">
          Regular Customer
          <input type="radio" name="discrate"   value="new customer">
          New Customer</label></td>

      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td width="47"><label>
          <input type="submit" name="btn" value="HIRE">
        </label></td>
        <td width="285"><label></label>
            <input type="reset"" name="reset" value="Reset"></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
      </tr>
    </table>
  </form>
  </div>
<div class="body"></div>
</body>
</html>

hi

i think you can first of all check the posted value by the php isset() function

<?
if(isset($_POST['discrate'])
{
   $val=$_POST['discrate'];
}
?>
echo "<tr><td>";

echo "<p><b>Discount Rate: </b>"<?=$val?>"</p>";

echo "</td></tr>";

Thanks

hello friend....how to validate multiple checkbox using php...nt js...

thx in advnce

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.