Tried asking this, it was marked duplicate with a suggestion. I employed the suggestions which still do not seem to be performing the desired result. Could someone actually read the following and advise where I am going wrong?
I am attempting to use sessions to pass the user selected data from this script (allotment.php) to a subsequent script (allotmentreport.php) wherein it is used in a query qualifier (e.g. ...WHERE tablecolumndata=session variable...). I am not getting an error from allotment.php upon selecting the option and clicking SUBMIT but data fails to pass to allotmentreport.php and returns an error for an undefined variable.
Is this and the line after it correct? Is there something I am missing otherwise? $tourselect=(isset($_POST['submit']));
UPDATE The final and corrected code is displayed below for future users seeking a working example and easy to read solution:
<?php
session_start();
$host="localhost";
$username="HIDDEN";
$password="HIDDEN";
$dbname="bookings2015";
$con = mysql_connect($host, $username, $password, $dbname);
if (!$con)
{
die ('damn thing wont connect to the MYSQL server: Maybe it is retarded '. mysql_error());
}
mysql_select_db($dbname, $con);
?>
<!Doctype html>
<html>
<?php include 'C:\xampp\htdocs\phpproject1\head.php';
include 'config\menu.php';
?>
<div id="dataentry">
<div id="submit">
<?php
echo "Which Tour to check availability? ";?>
<br />
<br />
</br>
</br>
<form method="post" action="allotment_report.php">
<select name='TourCode'>
<?php
$tourselection = "SELECT DISTINCT TourCode FROM toursanddates ORDER BY TourCode";
$result = mysql_query($tourselection);
while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['TourCode'] . "'>" . $row['TourCode'] . "</option>";
}
?>
</select>
<input type="submit" name="tourselected" value="submit">
</form>
<?php
?>
</div>
</div>
<div id="demographicborder">
<?php
include 'footer.php';?>
</div>
</div>
</body>
</html>
</form>
</form>
</div>
</div>
</div>
</body>
</html>
and here is the allotment_report.php code
<?php
session_start();
$host="localhost";
$username="STILLHIDDEN";
$password="STILLHIDDEN";
$dbname="bookings2015";
$con = mysql_connect($host, $username, $password, $dbname);
if (!$con)
{
die ('damn thing wont connect to the MYSQL server: Maybe it is retarded '. mysql_error());
}
mysql_select_db($dbname, $con);
include 'C:\xampp\htdocs\phpproject1\head.php';
include 'config\menu.php';
?>
<br />
<br />
<?php
//Table Header:
echo " <strong><u>Tour Availability</u>";
echo '<table align="center" cellspacing="3" cellpadding="3" width="75%">
<tr>
<td align=:"left"><b>Tour:</b></td>
<td align=:"left"><b>Start Date:</b></td>
<td align=:"left"><b>Seats Avail:</b></td>
<td align=:"left"><b>Rooms Avail:</b></td>
</tr>
';
if(isset($_POST['TourCode'])){
$tour=$_POST['TourCode'];
}
$status="ok";
$ar="SELECT TourCode, DATE_FORMAT (TourStart, '%m%d%y') AS TourStart, SeatsAvail, RoomsAvail FROM toursanddates WHERE TourCode='$tour' AND Status='$status' ORDER BY TourCode, TourStart ASC";
$result=mysql_query($ar);
$num_results = mysql_num_rows($result);
while($row = mysql_fetch_assoc($result)){
//Display the allotments fetched in above query
echo '<tr>
<td align=:"left">' . $row['TourCode'] . '</td>
<td align=:"left">' . $row['TourStart'] . '</td>
<td align=:"left">' . $row['SeatsAvail'] . '</td>
<td align=:"left">' . $row['RoomsAvail'] . '</td>
</tr>
';
}
echo '</table>';
//echo "</strong>Tour: ".($row['TourCode']);
//echo "</strong> Start Date: ".($row['TourStart']);
?>
<br />
<?php
echo "<br />";
echo "</p>";
?>
</br>
</br>
</div>
</form>
</div>
<div id="demographicborder">
<?php include 'footer.php';
?>
</div>
</div>
</body>
</html>
</form>
</form>
</div>
</div>
</div>
</body>
</div>
</body>