Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

my select options is not taking value at time of form submission

at the click of submit nothing happens

  • made just a simple dropdown box with select so i can fetch the value of it with post method but i am not getting what is wrong with the code*

this the PHP code

{
$option = ISSET($_POST['genre']) ? $_POST['genre'] : false;
if ($option) {
   echo HTML entities($_POST['genre'], ENT_QUOTES, "UTF-8");
} else {
  echo "task option is required";
  exit; 
}
}

this is the html code

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    <from method="post" action="file name">
        <select name="genre" id="genre" style="margin:8px;">
              <option selected disabled value="">Select genre</option>
              <option value="Action">Action</option>
              <option value="drama">Drama</option>
              <option value="sci-fi">Sci-fi</option>
              <option value="horror">Horror</option>
              <option value="romance">Romance</option>
              <option value="comedy">Comedy</option>
            </select>
            <input type="submit">
        </input>
    </from >

>Solution :

You have some spelling mistakes, try this one:

<form method="post" action="action.php">
    <select name="genre" id="genre" style="margin:8px;">
      <option selected disabled value="">Select genre</option>
      <option value="Action">Action</option>
      <option value="drama">Drama</option>
      <option value="sci-fi">Sci-fi</option>
      <option value="horror">Horror</option>
      <option value="romance">Romance</option>
      <option value="comedy">Comedy</option>
    </select>
    <input type="submit">
  </form>

action.php

if (isset($_POST['genre'])) {
  echo $_POST['genre'];
} else {
  echo 'Task option is required!';
  exit;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading