mardi 20 février 2018

Why won't the HTML select form element $_POST multiple values in PHP?

if (isset($_POST['ids']) && $_POST['ids'] === 'ford') {
  echo "yah!!!";
  print_r($_POST);
  $filename = "ford.txt";

} elseif (isset($_POST['ids']) && $_POST['ids'] === 'toyota') {
  print_r($_POST);
} elseif (isset($_POST['landrover']) && $_POST['ids'] === 'landrover') {

} elseif (isset($_POST['algonquin']) && $_POST['ids'] === 'algonquin') {

} elseif (isset($_POST['errors']) && $_POST['ids'] === 'errors') {

}

testing to see if $_POST superglobal array is posting. It is only posting one value 'ford'. Not sure why none of the other values aren't posting.

<form name="form" method="post" action="<?php echo $filename; ?>" target="box" >
    <select name="ids">
      <option value="ford">Ford</option>
      <option value="toyota">Toyota</option>
      <option value="landrover">Land Rover</option>
      <option value="algonquin">Algonquin</option>
      <option value="errors">Errors</option>
    </select>
    <input type="submit" name="submit" value="View File" />


  </form>

This is the form with all of the options and their values. It has a variable $filename which links to a text file which is meant to be opened in a target box. The if statement above is supposed to determine what file to open.

<iframe src="" name="box" width="100%" height="100%" frameborder="0"></iframe> The iframe or target box the file is supposed to open in.

Aucun commentaire:

Enregistrer un commentaire