Hello everyone!
I have a problem with radio buttons and php. I'm trying to pass the value of the radio button that has been selected, to another page.
I have a query:
$query = sprintf("SELECT bungalow_id, name, description, pricepernight, beds FROM bungalows WHERE bungalow_id <> ALL (SELECT bungalow_id FROM bungalow_diary WHERE date BETWEEN '$checkin_year-$checkin_month-$checkin_day' AND '$checkout_year-$checkout_month-$checkout_day')");
$check_date = mysql_query($query);
And then the code:
<?php while ($row = mysql_fetch_assoc($check_date)) { ?>
<div id="heading"> <input type="radio" name="chosen_bunga" value= "<?php echo $row['bungalow_id']; ?>"> <?php echo $row['bungalow_id']; echo $row['name']; ?> </div>
<div id="description"> <?php echo $row['description']; ?> <br>
Price: <?php echo $row['pricepernight']; ?> euro <br>
No of beds: <?php echo $row['beds']; ?> <br> </div>
<?php } ?>
<FORM name ="form1" method ="post" action ="./yourdetails.php">
<input type="hidden" name="chosen_name" value="rosana" >
<input type="hidden" name="chosen_bunga_name" value="<?php echo $_POST["chosen_bunga"]; ?>">
<input type="submit" name="book_submit" value="Book"> </FORM>
Now the "yourdetails.php" contains the following:
<?PHP
$selected_bunga = $_POST['chosen_name'];
$test = $_POST['chosen_bunga_name'];
print $selected_bunga;
print $test;
?>
So when I press the "Book" button, appears the "youdetails.php" page showing $test value which is "rosana". However the $selected_bunga has nothing in it, so it doesnt show anything.
Obviously the $chosen_bunga_name although it should, hasn't taken the value of the chosen radio button(value= "<?php echo $row['bungalow_id']; ?>"). Why does this happen?
I wonder if it is perplexed because of the query.
Any opinions?
Thanx in advance!