Jump to content

[SOLVED] weird problem with passing a POST value


jeff5656

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.