Skip to content Skip to sidebar Skip to footer

How To Get A Value Of HTML Drop Down Menu Using PHP?

I have a HTML script that has a dropdown menu with some options. Once you have selected your topic it goes to my PHP script called process.php. In that process.php it takes the val

Solution 1:

Try following code

<form id="form1" action="help.php" name="form1" method="post">
         <select name="pet" id="form">
          <option value="-1">--Select a Topic--</option>
          <option value="Dog">Dog</option>
          <option value="Cat">Cat</option>
          <option value="Other">Other</option>
        </select>
</form>

now option that you selected is accessible with $_POST['pet'] in php. also it's a good idea that set your default value to -1


Solution 2:

Give your select tag a "name" attribute.

<select name='form' id='form'>

You should also give your options the same "name" as the select.


Solution 3:

You have process.php in your question and the form action is help.php?

Also, try creating a file you know you have permission to write to, and then attempt to write to that file.


Post a Comment for "How To Get A Value Of HTML Drop Down Menu Using PHP?"