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> </p>
<h3><div id="content2" class="float_r">
<img src="images/logo.png" alt="OFO logo" />
<p> </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> </p>
<p> </p>
<p> </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";
}
?>