jeff5656 Posted July 13, 2009 Share Posted July 13, 2009 I am using the same bits of code from other files that work. Basically I have this form: <form name="newsubmit" method="post" action="commit.php"> [...] <?php $some_array = array("a"=>"Active","s"=>"Remove"); $signoff_status = $row['signoff_status']; print("<select name='signoff_status'>"); foreach($some_array as $key => $some_value) { print("<option value='$key' "); if($key == $signoff_status) { print(" selected"); } print(">$some_value</option>\n"); } print("</select>\n");?> when I echo back $signoff_status it says "a" which is appropriate for that record. but here is the file commit.php: <?php echo "signoff status is:" . $_POST['signoff_status']; and I get "signoff status is:" Huh? how did the POST become empty when the select part of the form had the correct value? This is an EXACT pasted code snip from my other forms that do work. FYI the field is ENUM and it is 'a','s' Thanks! Link to comment https://forums.phpfreaks.com/topic/165856-solved-weird-problem-with-passing-a-post-value/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 13, 2009 Share Posted July 13, 2009 Your form is probably invalid HTML. What does a "view source" of your whole form look like? Link to comment https://forums.phpfreaks.com/topic/165856-solved-weird-problem-with-passing-a-post-value/#findComment-874873 Share on other sites More sharing options...
jeff5656 Posted July 13, 2009 Author Share Posted July 13, 2009 Here is the view source: <select name='signoff_status'><option value='a' selected>Active</option> <option value='s' >Remove</option> </select> Isn't that correct? Link to comment https://forums.phpfreaks.com/topic/165856-solved-weird-problem-with-passing-a-post-value/#findComment-874890 Share on other sites More sharing options...
PFMaBiSmAd Posted July 13, 2009 Share Posted July 13, 2009 That's not a complete form, so the browser has no chance of sending any POST values. Link to comment https://forums.phpfreaks.com/topic/165856-solved-weird-problem-with-passing-a-post-value/#findComment-874894 Share on other sites More sharing options...
pengu Posted July 13, 2009 Share Posted July 13, 2009 I always thought it was something like <option selected="selected"> so I think the problem is the "<option value='a' selected>Active</option>" assuming of course the form is made correctly. Link to comment https://forums.phpfreaks.com/topic/165856-solved-weird-problem-with-passing-a-post-value/#findComment-874895 Share on other sites More sharing options...
jeff5656 Posted July 13, 2009 Author Share Posted July 13, 2009 What do you mean? I didnt post the entire form thats like 100 lines. The rest of the variables work. Is there soemthing wrong with the above <select> part of the form? I have a submit button etc. Do you need me to upload the entire code? Link to comment https://forums.phpfreaks.com/topic/165856-solved-weird-problem-with-passing-a-post-value/#findComment-874896 Share on other sites More sharing options...
pengu Posted July 14, 2009 Share Posted July 14, 2009 Change <select name='signoff_status'> <option value='a' selected>Active</option> <option value='s' >Remove</option> </select> To this.. (I think) <select name='signoff_status'> <option value='a' selected='selected'>Active</option> <option value='s' >Remove</option> </select> It may or may not be making something not work. Link to comment https://forums.phpfreaks.com/topic/165856-solved-weird-problem-with-passing-a-post-value/#findComment-874897 Share on other sites More sharing options...
PFMaBiSmAd Posted July 14, 2009 Share Posted July 14, 2009 selected='selected' is correct HTML, however just using selected works in at least FF (tested.) The posted select menu, when contained in a valid form, submits an 'a' for $_POST['signoff_status']. Something about your form or your form processing code is causing nothing to be submitted. The only way you can get specific help with what is wrong is if you post your code. Link to comment https://forums.phpfreaks.com/topic/165856-solved-weird-problem-with-passing-a-post-value/#findComment-874899 Share on other sites More sharing options...
jeff5656 Posted July 14, 2009 Author Share Posted July 14, 2009 I put the whole code in and then found out that the reason this didnt work is I had another part of the form that also had a <select> with the same name (signoff_status). I guess cutting and pasting from my other code has it's dangers LOL. Thanks to all... Link to comment https://forums.phpfreaks.com/topic/165856-solved-weird-problem-with-passing-a-post-value/#findComment-874901 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.