couldn't get hidden type data after form submission

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • selvialagar
    New Member
    • Apr 2008
    • 57

    couldn't get hidden type data after form submission

    i have two select boxes in my form named month and year...when i selected these two things, there is a submit button called 'generate invoice'. when i click this, invoice report is generated as a table on the same page and i put customer number and block number in the hidden field in this step.....i have another link called 'payment' in the generated table for each row...when i click that link the form gets once again submitted....bu t, when i am going to retrieve the hidden field data(customer number and block number) i couldn't get that data...why? my code is here

    plz solve this problem...
    [code=php]
    <?php
    require_once('d atabase_conn.ph p');
    session_start() ;
    if(isset($_SESS ION['username']))
    {
    ?>
    <html>
    <head>
    <title>Proper ty Management System</title>
    <style>
    .edit
    {
    text-decoration:unde rline;
    cursor:pointer;
    color:blue;
    }
    </style>
    <script type="text/javascript">
    function month_display()
    {
    if(document.get ElementById('bi llmonth').value =="nil")
    {
    alert("Please Select Month");
    }

    }
    function year_display()
    {
    if(document.get ElementById('bi llyear').value= =0)
    {
    alert("Please Select Year");
    }
    }
    function payment()
    {
    document.forms[0].submit();
    }
    function validate()
    {
    var error="";
    if(document.get ElementById('bi llmonth').value =="nil")
    {
    error +="Please Select Month\n";
    }
    if(document.get ElementById('bi llyear').value= =0)
    {
    error +="Please Select Year\n";
    }
    if(error)
    {
    alert(error);
    return false;
    }
    else
    {
    return true;
    }
    }
    </script>
    </head>
    <body>
    <?php
    include('adminl ogin.php');
    ?>
    <form action="bill_in dex.php" method="post" name="cust" onsubmit="javas cript:return validate();">
    <?php
    if (isset($_POST['custno']))
    {
    $custno=$_POST['custno'];
    echo $custno;
    }
    else
    {
    ?>
    <table border="0" align="center" cellspacing="1" cellpadding="2" class="bg1">
    <div style="position :absolute;left: 600px;top:80px; "><input type="text" name="bill_date " readonly="reado nly" id="bill_date" value="<?php echo date("F j, Y");?>" class="textfiel d" size="10" /></div>
    <tr class="bg2"><td >Rent for the Month :</td><td>
    <select name="billmonth " id="billmonth" class="bg2" onChange="month _display()">
    <option value="nil">--Select--</option>
    <?php
    $mnth=array(1=> "Jan",2=>"Feb", 3=>"Mar",
    4=>"Apr",5=>"Ma y",6=>"Jun",
    7=>"Jul",8=>"Au g",9=>"Sep",10= >"Oct",11=>"Nov ",12=>"Dec" );
    if(isset($_POST['billmonth']))
    {
    foreach($mnth as $k=>$v)
    {
    if($k==$_POST['billmonth'])
    {
    ?>
    <option value="<?php echo $k;?>" selected="selec ted"><?php echo $v;?></option>
    <?php
    }
    else
    {
    ?>
    <option value="<?php echo $k;?>"><?php echo $v;?></option>
    <?php
    }//else
    }//for
    }//if
    else
    {
    foreach($mnth as $k=>$v)
    {
    ?>
    <option value="<?php echo $k;?>"><?php echo $v;?></option>
    <?php
    }
    }
    ?>
    </select></td><td>
    Year<select name="billyear" id="billyear" class="bg2" onchange="year_ display()">
    <option value="0">--Select--</option>
    <?php
    $yr=array(2007, 2008,2009);
    if(isset($_POST['billyear']))
    {
    for($i=0;$i<cou nt($yr);$i++)
    {
    if($yr[$i]==$_POST['billyear'])
    {
    ?>
    <option value="<?php echo $yr[$i];?>" selected="selec ted"><?php echo $yr[$i];?></option>
    <?php
    }
    else
    {
    ?>
    <option value="<?php echo $yr[$i];?>"><?php echo $yr[$i];?></option>
    <?php
    }//else
    }//for
    }//if
    else
    {
    for($j=0;$j<cou nt($yr);$j++)
    {
    ?>
    <option value="<?php echo $yr[$j];?>"><?php echo $yr[$j];?></option>
    <?php
    }
    }
    ?>
    </select>
    </td></tr>
    </table><br />
    <center>
    <input type="submit" name="gen_invoi ce" id="gen_invoice " value="Generate Invoice" class="button" /></center>
    <br />
    <?php
    if(isset($_POST['billmonth']) && isset($_POST['billyear']) && isset($_POST['gen_invoice']))
    {
    ?>
    <table border="0" cellspacing="1" cellpadding="2" class="bg1" align="center">
    <tr>
    <td><div align="center"> Serial No</div></td>
    <td><div align="center"> Customer Name</div></td>
    <td><div align="center"> Building Name</div></td>
    <td><div align="center"> Floor No</div></td>
    <td><div align="center"> Block Name</div></td>
    <td><div align="center"> Rent(Rs.)</div></td>
    <td><div align="center"> Payment</div></td>
    </tr>
    <?php
    $flblno=mysql_q uery("select build_name,floo r_no,block_name ,pms_rental.ren t,pms_rental.bl ock_id,pms_cust omer.cust_name, pms_customer.cu st_id from pms_block,pms_c ustomer,pms_ren tal where pms_block.block _id=pms_rental. block_id and pms_rental.cust _id=pms_custome r.cust_id") or die('Unable to perform the operation');
    $cou=1;
    while($fl=mysql _fetch_object($ flblno))
    {
    ?>
    <tr class="bg2">
    <td><?php echo $cou;?></td>
    <td><?php echo $fl->cust_name;?> </td>
    <td><?php echo $fl->build_name;? ></td>
    <td><?php echo $fl->floor_no;?></td>
    <td><?php echo $fl->block_name;? ></td>
    <td><?php echo $fl->rent;?></td>
    <td><a href="" name="pay_link" onclick="javasc ript:payment(); ">Payment</a></td></tr>
    <input type="hidden" name="custno" value="<?php echo $fl->cust_id;?>" />
    <input type="hidden" name="blno" value="<?php echo $fl->block_id;?>" />
    <?php
    $cou++;
    }
    ?>
    <?php
    }
    ?>
    </table>
    <?php
    }
    ?>
    </form>
    </html>
    <?php
    }

    else
    {
    header("locatio n:login_index.p hp");
    }
    ?>

    [/code]
    Last edited by ronverdonk; Apr 9 '08, 02:45 PM. Reason: code breaks page
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Do you mean that you don't get the names of the hidden fields in your $_POST array or that these fields ar in the $_POST array but have no value assigned to them?

    Ronald

    Comment

    Working...