Transfer value from tag select to php

Discuss coding issues, and scripts related to PHP and MySQL.
mlucicom
Posts: 37

Transfer value from tag select to php

I have some select options:

Code: Select all

<select name="array[]" value="a">First</select>
<select name="array[]" value="ab">First2</select>
<select name="array[]" value="abc">First3</select>
<a href="prelucrate.php">Your selected values</a>
When user go to prelucrate.php page i want to display his select values

Admin Posts: 805
Hello,
To transfer value from <select> tag to php you need to use <option> elements in <select>, and send data via a form with Submit button (or some javascript).
The "value" is added in <optioin>.
For example, you can use something like this:

Code: Select all

<form action="prelucrate.php" method="post">
<select name="some_name">
<option value="a">First1</option>
<option value="ab">First2</option>
<option value="abc">First3</option>
</select>
<input type="submit" value="send" />
</form>
Then, in php:

Code: Select all

$vr_name = isset($_POST['some_name']) ? $_POST['some_name'] :'';
echo $vr_name;

Similar Topics