Using a drop down list I am selecting a data from a list :
<option value="R.K.Hospital">R.K.Hospital </option>
<option value="Sevabhai Hospital">Sevabhai Hospital</option>
Now Using this part of the code I am checking whether the seat is available or not :
$queryreg = mysql_query("SELECT available FROM hospital WHERE h_name='$hospital' ");
$queryreg = mysql_fetch_assoc($queryreg);
$a= $queryreg;
echo '<span style="color:ff0000;text-align:center;">Available seats are , '.$a['available'].' </span>';
if($a['available']>0)
{
echo (" <form action='book_bed.php' method='post'><input name='submit' type='submit' value='Book Now' /> </form>");
}
Now I want to book the seat if the seats are available...
<?php
include_once('connection.php');
include_once('available.php');
$hospital=$_POST['hospital'];
$username=$_SESSION['username'];
$date=date("Y-m-d");
if(@$_POST['submit'])
{
$queryreg = mysql_query("INSERT INTO `bed_book` VALUES ('$username','$hospital','')",$connect);
echo'<span style="color:#AFA;text-align:center;">Order Has Been Booked !!</span>';
}
?>
Everything is getting inserted in the database except the $hospital variable... I guess there is some implementation problem...The connection and the database is working quite finely so there is not an issue. If anybody can help I'll be thankful...
In your form there is no any input for hospital
echo (" <form action='book_bed.php' method='post'>
<input name='hospital' type='hidden' value='".$hospital."' />
<input name='submit' type='submit' value='Book Now' />
</form>");
and on submit of it you will get value of it
$queryreg = mysql_query("INSERT INTO `bed_book` VALUES ('$username','".$hospital."','')",$connect);