0

i have two forms on 1 page. but the 2nd form keep going to 1st form action.. 2nd form suppose to go to approve.php..how do i solve this?
when i click Approve it suppose to go to approve.php and execute the query there..but now when i click it give errors:
Notice: Undefined index: odate in /home/lh026/public_html/COMP1161/astockoutlet.php on line 7

Notice: Undefined index: outlet in /home/lh026/public_html/COMP1161/astockoutlet.php on line 8

here is astockoutlet.php

<?php
include_once 'admin-class.php';
$admin = new itg_admin();
$admin->_authenticate();

$date =  date("Y-m-d",time() + (8 * 3600));
$orderdate=$_POST['odate'];
$outlet = $_POST['outlet'];
$con=mysql_connect("studb.cms.gre.ac.uk","lh026","fizztm7F");
mysql_select_db("mdb_lh026", $con);
$id=$_SESSION['admin_login'];
$result2 = mysql_query("SELECT orderdb.odate,orderdb.itemcode,orderdb.quantity,orderdb.saiz,orderdb.remark,  
 pstaff.outlet  
FROM orderdb ,pstaff  
WHERE  orderdb.staff_id =pstaff.staff_id
AND pstaff.outlet='$outlet'
AND orderdb.odate='$orderdate' ORDER BY odate DESC");
$nume=mysql_num_rows($result2);

$pdate = mysql_query("SELECT odate 
FROM orderdb 
WHERE odate='$orderdate'
");
list($page_date) = mysql_fetch_row($pdate);

$poutlet = mysql_query("SELECT outlet 
FROM pstaff 
WHERE outlet='$outlet'
");
list($page_outlet) = mysql_fetch_row($poutlet);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <title><?php echo $page_date.'|'.$page_outlet; ?></title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="css/reset.css" type="text/css" media="all">
    <link rel="stylesheet" href="css/grid.css" type="text/css" media="all">
    <link rel="stylesheet" href="css/style.css" type="text/css" media="all">
    <!--[if lt IE 9]>
        <script type="text/javascript" src="js/html5.js"></script>
    <![endif]-->
    <script>
function validate()
{
    if (document.forms["contact-form"]["outlet"].value=="") { 
    alert("Please choose an outlet");
    return false; 
    }
    else if (document.forms["contact-form"]["odate"].value=="") { 
    alert("Please choose a date");
    return false; 
    }

}
    function printDiv(content2) {
     var printContents = document.getElementById(content2).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}

    </script>


</head>

<body>
    <header>
        <nav>
            <div class="container">
                <div class="wrapper">
                    <a href="aindex.php"><img src="images/logo.png" alt="OFO logo" /></a>
                    <ul>
                        <li><a href="astock.php" class="current">View Order</a></li>
                        <li><a href="astockview.php">View Pending</a></li>
                        <li><a href="index-2.html">industries</a></li>
                        <li><a href="index-3.html">contacts</a></li>
                    </ul>
                </div>
            </div> 
            <li style="color:#CCC" style="font-size:medium"><?php
if(isset($_SESSION['admin_login'])){
    echo( 'Welcome    '.$admin->get_name().' >>>'.'<a href="logout.php">Logout</a>');}
?> </li>
        </nav>
        <section class="adv-content">
            <div class="container">
                <ul class="breadcrumbs">
                    <li>Industries</li>
                </ul>
                <form action="" id="search-form">
                    <fieldset>
                        <input type="text" value=""><input type="submit" value="">
                    </fieldset>
                </form>
            </div>
        </section><div class="ic">###</div>
    </header>
    <section id="content">
        <div class="top"><span class="field">

        </span>
            <div class="container">
                <div class="clearfix">
                  <div class="grid9 first">
                        <h2>Stock Order</h2>
                        <form id="contact-form" action="astockoutlet.php" onsubmit="return validate()" method="post" enctype="multipart/form-data">
                      <fieldset>
                          <h4><label><span class="text-form">Outlet:</span>
                          <select name="outlet" id="outlet"> 
                          <option value="">Select outlet</option>
                            <option value="GKK">Giant Kulim,Kedah</option>
                            <option value="TMK">TESCO Mutiara, Sg. Petani,Kedah</option>
                            <option value="SAP">Jalan Sultan Ahmad Shah,Penang</option>
                            <option value="ACP">Autocity, Juru Interchange,Penang</option>
                            <option value="CTP">Cheruk Tokun, Alma,Penang</option>
                            <option value="SQP">Straits Quay,Penang</option>
                            <option value="TTP">TESCO Taiping,Perak</option>
                            <option value="KBK">Kota Bharu,Kelantan</option>
                            <option value="TS9">TESCO Seremban 2,Negeri Sembilan</option>
                            <option value="TMM">TESCO Melaka Cheng,Melaka</option> 
                          </select>
                        </label>
                        Order Date: <input type="date" name="odate">
                    </h4>
                        </fieldset><p></p>
                      <input type="submit" name="submit" value="View Order" />


                </form>
                 <p>&nbsp;</p>
                    <h3><div id="content2" class="float_r">

                        <img src="images/logo.png" alt="OFO logo" />
                        <p>&nbsp;</p>

                      <p><strong><font color="red">
                            <?php 

          if($nume==0)
          {  echo "You currently have no item to show"; }
          else if(isset($_GET['msg']))
          {
            $msg = $_GET['msg'];
            if($msg!='')
            { 

             '<table border="1">
                <tr>
                <td><font color="red">'.$msg.'</font></td>
                </tr>
                </table>';
            }
        } 
            ?>
                            </font></strong></p>
                          <table width="713" cellspacing="0" cellpadding="5">
                            <tr bgcolor="#ddd">
                              <th width="107" align="left">Date </th>
                              <th width="98" align="left">Item Code </th>
                              <th width="89" align="left">Quantity</th>
                              <th width="59" align="left">Size </th>
                              <th width="263" align="left">Remark</th>
                              <th width="18" align="left">Outlet</th>
                              <th width="7"> </th>
                            </tr>
                            <?php

        $start=(isset($_GET['start'])) ? (int)$_GET['start']:0;

            if(strlen($start) > 0 and !is_numeric($start))
            {
                echo "Data Error";
                exit;
            }

            $eu = ($start - 0); 
            $limit = 5;                           
            $this1 = $eu + $limit; 
            $back = $eu - $limit; 
            $next = $eu + $limit; 
            $date =  date("Y-m-d",time() + (8 * 3600)); 

            $result = mysql_query("SELECT orderdb.odate,orderdb.itemcode,orderdb.quantity,orderdb.saiz,orderdb.remark,  
 pstaff.outlet  
FROM orderdb ,pstaff  
WHERE  
pstaff.outlet='$outlet'
AND orderdb.odate='$orderdate' 
ORDER BY odate DESC
");

            while($row = mysql_fetch_array($result))
            {
                echo "<tr>";

                echo "<td>".$row['odate']."</td>";

                echo "<td>".$row['itemcode']."</td>";

                echo "<td>".($row['quantity'])."</td>";

                echo "<td>".($row['saiz'])."</td>";

                echo "<td>".($row['remark'])."</td>"; 

                echo "<td>".($row['outlet'])."</td>";

                echo "</tr>";
            }


        mysql_close($con);
                        ?>
                          </table>
                        <p>&nbsp;</p>
                        <p>&nbsp;</p>
                        <p>&nbsp;</p>
                        <form id="approve" action="approve.php"  method="post" enctype="multipart/form-data">
                          <table class="formtable1">
        <tr>
                                    <td height="35" class="label"><label for="outlet">Outlet:</label></td><td class="field"> <input  name="outlet1" type="text" class="txtfield" value="<?php echo $outlet?>" disabled/></td>

                                    <td height="35" class="label"><label for="date1">Date:</label></td>
                                    <td class="field"> <input  name="date1" type="text" class="txtfield" value="<?php echo $orderdate?>" disabled/></td>
                                </tr>  
         <tr>
                                <td height="35" class="label"><label for="generate">Generate by:</label></td>
                                <td class="field"> <input  name="name" type="text" class="txtfield" value="<?php echo $admin->get_name();?>" disabled/></td>

                                <td height="35" class="label"><label for="random">Confirm Code:</label></td>
                                <td class="field"> <input  name="confirm1" type="text" class="txtfield" value="<?php echo $admin->generateCode();?>" disabled /></td>             
                                </tr>   
                                 <tr>
                                <td height="35" class="label"><label for="dategenerate">Generate Date:</label></td>
                                <td class="field"> <input  name="date" type="text" class="txtfield" value="<?php echo $date?>" disabled/></td>

                                </tr>                 
                         </table>
<input type="submit" name="submit1" value="Approve" />

</form>

</div>
<input type="button" onclick="printDiv('content2')" value="Print" />
                    </h3>
                  </div>

                </div>
            </div>
        </div>


    </section>
    <footer>
        <div class="container">
            <div class="wrapper">
                <div class="copy">OFO Over-run Factory Outlet<a href="index-4.html">rivacy policy</a></div>
                <address class="phone">
                    ofo.com.my<strong></strong>
                </address>
            </div>
        </div>
    </footer>
</body>
</html>

approve.php

<?php
include_once 'admin-class.php';
$admin = new itg_admin();
$admin->_authenticate();


if (isset($_POST['submit1']))
{
    $id=$_SESSION['admin_login'];
        $date1=$_POST['date1'];
        $outlet1=$_POST['outlet1'];
        $confirm=$_POST['confirm1'];

$con=mysql_connect("studb.cms.gre.ac.uk","lh026","fizztm7F");
mysql_select_db("mdb_lh026", $con);

$stock=mysql_query("SELECT * FROM orderdb WHERE odate='$date1' AND outlet='$outlet1'
                        ");
                        $allstock=mysql_num_rows($stock);   


        if($stock!=0){


        $result = mysql_query("UPDATE orderdb
SET confirmcode='$confirm'
WHERE odate='$date1' AND outlet='$outlet1'");


$msg = "Delivery order has been saved.";
    header("location:astockoutlet.php?msg=$msg");
                            }

                                                    else {
                                $msg="This outlet or date dont have order.";
                                header("location:astockoutlet.php?msg=$msg");                           
                                                        }

mysql_close($con);
}
else 
{
    echo "NOT isset submit";
}



?>

Edited by pritaeas: Moved

4
Contributors
5
Replies
29
Views
4 Years
Discussion Span
Last Post by diafol
0

On line 113 in the code above, change the form action to

form action="approve.php"

Now it is astockoutlet.php, which is the same page as the first form...

Works?

Edited by klemme

0
Notice: Undefined index: odate in /home/lh026/public_html/COMP1161/astockoutlet.php on line 7

Notice: Undefined index: outlet in /home/lh026/public_html/COMP1161/astockoutlet.php on line 8

Didn't I fixed those errors the last time we spoken?

Why are you having this undefined index again?

Edited by LastMitch: grammer

0

Because the forms action and post values are not being recieved on the page he wants to, right? Not pointing to approve.php.

This line:

1.Notice: Undefined index: odate in /home/lh026/public_html/COMP1161/astockoutlet.php on line 7

Should be this line:

1.Notice: Undefined index: odate in /home/lh026/public_html/COMP1161/approve.php on line 7

Just without the notice..Maybe you fixed it for him last, but doesnt looks like he did the changes :-)

But is not set in the form action of form no.2.

Regards, Klemme

Edited by klemme

0

Because the forms action and post values is not being recieved on the page he wants to, right?

Yes, plus he post a few files already with this undefine index error.

I can't believe he didn't look back the last couple thread(s) that he post which show how to remove the undefine index error.

0

That mix of php and html with inline properties, and js is v. difficult to follow. Have you tried separating all the different components in order to streamline your files?
The js validation can be used with event listeners, e.g.

object.onclick=function(){
    ...
};

This takes away the need to pollute your html with inline onClick().

I'd suggest you break up the first file into a number of smaller units.
In addition the php is intrusive, you could be able to write a bunch of functions (or a class) that could let you make it a lot cleaner, where you just need to echo a variable or a function output.

For example, this:

   while($row = mysql_fetch_array($result))
   {
            echo "<tr>";
            echo "<td>".$row['odate']."</td>";
            echo "<td>".$row['itemcode']."</td>";
            echo "<td>".($row['quantity'])."</td>";
            echo "<td>".($row['saiz'])."</td>";
            echo "<td>".($row['remark'])."</td>"; 
            echo "<td>".($row['outlet'])."</td>";
            echo "</tr>";
   }

could be placed in a user-defined function or a class method in an include file:

function getData(){
    //do connection and sql stuff here first
    $out = '';
    //...
    while($row = mysql_fetch_array($result))
   {
            $out .= "<tr>";
            $out .= "<td>".$row['odate']."</td>";
            $out .= "<td>".$row['itemcode']."</td>";
            $out .= "<td>".($row['quantity'])."</td>";
            $out .= "<td>".($row['saiz'])."</td>";
            $out .= "<td>".($row['remark'])."</td>"; 
            $out .= "<td>".($row['outlet'])."</td>";
            $out .= "</tr>";
   }
   //...
   return $out
}

Then in your page:

<?php if(...) echo getData();?>

A single line.

ANyway, just an idea. I can't go on specifics as I'm finding the code difficult to follow.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.