Hi,
I'm trying to post through a value of a button from a form on a previous page, and depending on the button that was pressed, an SQL statement will be executed and then a table will be created based on the result. However, when i try to do this i get an error message:
PHP Notice: Undefined index: both in D:\Web\Tivicheck\getinfo.php on line 11
The relevent code for the first form is..
<form action="getinfo.php" method="POST">
<select name=t1>
<?php
while (odbc_fetch_row($rs))
{
$location=odbc_result($rs,"Location");
echo "<option>";
echo $location;
}
?>
</select>
<select name=t2>
<?php
$sql2="SELECT DISTINCT Responsible FROM BackupLog";
$rs2=odbc_exec($conn,$sql2);
while (odbc_fetch_row($rs2))
{
$responsible=odbc_result($rs2,"Responsible");
echo "<option>";
echo $responsible;
}
odbc_close($conn);
?>
</select>
<input type=Submit name="one" value="Location">
<input type=Submit name="both" value="Location and Responsible">
</div>
</div>
</body>
</html>
and the second page code is as follows:
<?php
$conn=odbc_connect('backuplogs','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$postlocation = $_POST['t1'];
$postresponsible = $_POST['t2'];
if($_POST['both'] == 'Location and Responsible') {
$results="SELECT * FROM BackupLog WHERE
Location = '$postlocation'
AND Responsible = '$postresponsible'";
$rs=odbc_exec($conn, $results);
while (odbc_fetch_array($rs)){
$servername=odbc_result($rs, "Servername");
$results2 = odbc_result_all($rs, "border=1");
echo $results2;
}
echo "</table>";
}
else
{
$singleresults="SELECT * FROM BackupLog WHERE
Location = '$postlocation'";
$rs2=odbc_exec($conn, $singleresults);
while (odbc_fetch_array($rs2)){
$servername=odbc_result($rs2, "Servername");
$results3 = odbc_result_all($rs2, "border=1");
echo $results3;
}
echo "</table>";
}
Any help is appreciated, thanks.