Andres Scarpone
Andres Scarpone

Reputation: 29

Variable sent through POST Method brings lots of blank spaces PHP

Thanks everyone adding the name to the select tag did the trick.

but now the value that is sent trough the post method is something like this

$_document =                   Andres

with lots of blank spaces and i wish to obtain something clean like

$_document=Andres

Any ideas?

I'm having troubles with a variable that needs to be sent through POST method. Heres the code:

 <td>
   <label>Nombre</label><input type="text" id="_name" name="_name" value="<?=$_name?>" class="name" />
   <label>URL</label><input type="text" id="_permalink" name="_permalink" value="<?=$_permalink?>" class="name" />
   <label>Fecha</label><input type="text" id="_date" name="_date" value="<?=date_to_javascript_short($_date)?>" />
   <input type="checkbox" id="_featured" value="s" name="_featured" class="checkbox" <?= $_featured == "s" ? "checked='checked'" : "" ?> /><label for="_featured" class="checkbox">Marcar como relevante</label>

  <label>Carpeta</label>

  **<select>
      <?  $document = process_all("SELECT _document_name FROM _document WHERE _owner = 'Marco Regulatorio' ORDER BY _document_name ");
      if($document) {
       foreach ($document as $item) {
         echo "<option id='_document' value=' ";?>
         <?=$_document=$item[_document_name]?>
         <?echo "'>";
         echo "$item[_document_name] </option>";        
        }
      }
        ?>
      </select>**
   </td>

The $_name, $_permalink and other variables are sent correctly using the post method the one that gives the problem is the one in the select tag, the $_document variable, first to explain is that I get the content for the options tag using a DB, then I set the options that will show using PHP for it but I really don't get why wont it send the $_document variable using the post method.

Upvotes: 0

Views: 155

Answers (2)

andho
andho

Reputation: 1172

The select doesn't have a name to be sent as.

Just add a name attribute to the select tag and try.

Upvotes: 1

Kaken Bok
Kaken Bok

Reputation: 3395

Give the select tag the name "_document" the way you named the input "_name".

Upvotes: 1

Related Questions