Jump to content

Simple? posting variable


dannyone

Recommended Posts

hey everyone, im having a bit of trouble with this page i am creating. i have a page where the user selects the room they want from a drop down list and they then submit this and are taken to a new page were they can update and view the details of that room.

at the moment i am posting the value selected, and if i do an echo of it, it displays the right details. however when i go to update the details it saves them as room-id 0 instead of the room selected, can some1 have a quick look and see where i am going wrong, its probably something silly im missing. thanks

 

<?php
$nt = $_POST['Room_ID'];

echo "$nt";      
// this echo displays the correct room selected from the previous page!

@$todo=$_POST['todo']; // take care of register global if off
if(isset($todo) and $todo=="submit_form"){
$days_array=$_POST['days_array'];
$tag_string="";
while (list ($key,$val) = @each ($days_array)){
//echo "$val,";
$tag_string.=$val.",";
}
$tag_string=substr($tag_string,0,(strLen($tag_string)-1));
$result=(mysql_query(sprintf("update Rooms_Free set timeslot='$tag_string' where Room_ID='$nt'")));
if(mysql_affected_rows()==0) {
$result=mysql_query("INSERT INTO Rooms_Free (Room_ID, timeslot) VALUES('$nt', '$tag_string')");
echo "<br /><FONT COLOR = RED>Room Availability Updated!</FONT COLOR><br /><br /><br />"; 
}else{echo mysql_error();}

}
?>

 

thanks again

Link to comment
https://forums.phpfreaks.com/topic/149514-simple-posting-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.