undefined index

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

    undefined index

    [code=php]
    <?php
    require_once('d atabase_conn.ph p');
    session_start() ;
    if(isset($_SESS ION['username']))
    {
    if(isset($_GET['action']) && $_GET['action']=="submit")
    {
    $cust_id=$_POST['cname'];
    echo $cust_id;
    }
    else
    {
    ?>
    <html>
    <head>
    <script type="text/javascript">
    function cust_display()
    {
    if(document.get ElementById('cn ame').value==0)
    {
    alert("Please Select Customer Name");
    }
    else
    {
    document.getEle mentById('cust_ id').value=docu ment.getElement ById('cname').v alue;
    alert(document. getElementById( 'cust_id').valu e);
    window.location ="bill_index.ph p?action=submit ";
    }
    }
    </script>
    </head>
    <body>
    <?php
    include('adminl ogin.php');
    ?>
    <form action="#" method="post" name="cust">
    <br />
    <center>
    Select Customer Name :
    <select name="cname" id="cname" class="bg2" onChange="cust_ display()">
    <option value="0">--Select--</option>
    <?php
    $query=mysql_qu ery("select cust_name,cust_ id from pms_customer");
    while($r=mysql_ fetch_object($q uery))
    {
    ?>
    <option value="<?php echo $r->cust_id;?>"><? php echo $r->cust_name;?> </option>
    <?php
    }

    ?>
    </select>

    </form>
    <input type="hidden" name="cust_id" id="cust_id" />
    <?php
    }
    ?>
    </html>
    <?php
    }
    else
    {
    header("locatio n:login_index.p hp");
    }
    ?>

    when i execute this program....unde fined index ...error appers....how to solve thi s problem....
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Try this:[php]if ( isset($_GET['action']) & $_GET['action']=="submit")[/php]
    * note the single ampersand

    If doesn't work, then break this if loop into two if conditions.[php]if ( isset($_GET['action']) && $_GET['action']=="submit")[/php]
    as...
    [PHP]if (isset($_GET['action']))
    {
    if ($_GET['action']=="submit")
    {
    //------- write the code here
    }
    }[/PHP]

    Comment

    Working...