I have a form with several fields and with 4 radio buttons. Based on this radio button click, the form has to be validated. All the fields in the form need not be validated.
Check this link, the similar thing I want:
The code i tried:
<?php
$guestname="";$validguestname="";
$guestno= "";$validguestno="";
$nochild= 0;$validnochild="";
$noadults=0;$validnoadults="";
$infants =0;$validinfants="";
$noofperson ="";$validnoofperson="";
$check_in="";$validdate1="";
$check_out="";$validdate2="";
$noofnight = "";$validnoofnight="";
$room_type="";$validroom_type="";
$nfroom="";;$validnfroom="";
$noofextrabed ="";$validnoofextrabed="";
$roomarray="";$validroomarray="";
$mealplan="";$validmealplan="";
$rateperday ="";$validrateperday="";
$rateperbed ="";$validrateperbed="";
$total_amount ="";$validtotal_amount="";
$advance = "";$validadvance="";
$balance ="";$validbalance="";
$receiptno ="";$validreceiptno="";
$dateofremitance ="";$validdateofremitance="";
$bankorcash="";$validbankorcash="";
$bank_name="";$validbank_name="";
$bookedby="";$validbookedby="";
$paymentmode ="";$validpaymentmode="";
$bookingtype="";$validbookingtype="";
$reservationstatus="";$validreservationstatus="";
$book_by="" ;$validbook_by="";
$agentname= "";$validagentname="";
$agentphoneno="";$validagentphoneno="";
$error_message="";$error_message1="";$error_message2="";
$date3=date('Y-m-d');
if(isset( $_POST['submit']))
{
$guestname= $_POST['guest_name'];
$bookingtype=$_POST['booking_type'];echo $bookingtype."helooo";
$guestno= $_POST['guest_no'];
$reservationstatus=$_POST['reservation_status'];
$nochild= $_POST['no_child'];
$book_by= $_POST['bookby'];
$agentname= $_POST['bookbyother'];
$agentphoneno= $_POST['phone1'];
$noadults= $_POST['no_adults'];
$infants = $_POST['no_infants'];
$noofperson = $nochild+$noadults+$infants;
$check_in=trim( $_POST['checkin']);
$check_out=trim( $_POST['checkout']);
$noofnight = $_POST['no_of_days'];
$room_type= $_POST['roomtype'];
$nfroom= $_POST['noofroom'];
$noofextrabed = $_POST['no_of_extra_bed'];
$roomarray= $_POST["room_no"];
$mealplan= $_POST['meal_plan'];
$rateperday = $_POST['rp_day'];
$rateperbed = $_POST['extrarate'];
$total_amount = $_POST['totalamount'];
$advance = $_POST['advance_amount'];
$balance = $_POST['val_username'];
$receiptno = $_POST['receipt_no'];
$dateofremitance = $_POST['date_remitance'];
$bankorcash= $_POST['paymentmode'];
$bank_name= $_POST['bankname'];
$booking_date=date('y-m-d');
$bookedby= $_POST['adminbooking'];
$paymentmode = $_POST['payment_mode'];
$date1 = date('Y-m-d', strtotime($check_in));
$date2 = date('Y-m-d', strtotime($check_out));
///1st condition///
if($bookingtype=="direct" && $reservationstatus=="H" && other_conditions)
{
insert query;
}
///2nd condition///
else if($bookingtype=="direct" && $reservationstatus=="C" && othercondition for particular fields)
{insert query;}
///3rd condition///
else if($bookingtype=="agent" && $reservationstatus=="H" && $book_by=="other")
{echo "agent anfd holding and other";}
///4th condition///
else if($bookingtype=="agent" && $reservationstatus=="H" && $book_by!="other")
{echo "agent anfd holding and not toher";}
///5th condition///
else if($bookingtype=="agent" && $reservationstatus=="C" && $book_by=="other")
{echo "agent anfd confirm and other";}
///6th condition///
else if($bookingtype=="agent" && $reservationstatus=="C" && $book_by!="other")
{echo "agent anfd confirm and not other";}
//else condiition
else
{echo "choose ur option";}