-1

I'm having difficulty assigning a PHP variable to a HTML form data.

I have assigned other text fields as variable but when I mimic this in a function it's just not playing ball...

My HTML code (only basic to start off) is:

<select id="userbrand">
<option> Option1</option>
<option> Option2</option>
<option> Option3</option>

and the corresponding PHP code is:

$camp_name = $_POST['campName'];
$broad_date = $_POST['broadDate'];
$userdomain = $_POST['userbrand'];

campName and broadDate contain the POST data from some text fields before the dropdown.

When submitting the form, I receive the following error:

Notice: Undefined index: userbrand in C:\wamp64\www\action_page.php on line 19

Is this an issue with my PHP code or my HTML?

Many Thanks in Advance

Andrew M
  • 3
  • 1
  • 2

1 Answers1

0

Change this

<select id="userbrand">

To this

<select id="userbrand" name="userbrand">

PHP gets the input value based on the input name, not the id.

DiddleDot
  • 745
  • 5
  • 16