Get result from <select> in php

How do I get the option people click from the select in html?

example:

<select name="searchType" class="form-control">
<option value="1" selected="selected">option1</option>
<option value="2">option2</option>
</select>

and i’m trying to make it so in php i can do this:

if option1 is selected then do this

$query = mysqli_query($connection,"SELECT * FROM accounts WHERE username LIKE '$searchkey'");

but if option2 is selected then do this

$query = mysqli_query($connection,"SELECT * FROM accounts WHERE email LIKE '$searchkey'");

For starters, the select tag, along with any other input boxes, plaintext boxes etc. involved in your user input, must be embedded in a <form> tag on the client side. You give the form a method using HTML tag attributes like <form method=”GET” action=”/submit.php”> where /submit.php is the location of the PHP file you’re using to process the request.

Back on the server side, when the GET or POST comes in, you can get the attributes using $_GET or $_POST. See for yourself at the top of your form handling PHP script by calling var_dump($_GET) and testing out a form submission. That will dump the data to your browser, showing you the fields you submitted in the form (organized in the assoc array by name).