I have a code in html-PHP that is the following
<form action="index2.php?idubicacion=<?php echo $row['ID'];?>" method="GET" >
<select>
<?php
include("conexion.php");
$query = "SELECT * FROM tbubicaciones";
$resultado = $conexion->query($query);
while($row = $resultado ->fetch_assoc()){
?>
<option value="<?php echo $row['ID']; ?>" /><?php echo $row['Ubicacion']; ?></option>
<?php
}
?>
</select>
<input type="submit" name="Aceptar" >
</form>
where I show certain locations in a list and they take an ID as a value, example:
ID | locations
1 | LIVING ROOM
2 | KITCHEN
What I am looking for is to send the ID value by URL and collect it in another PHP but I can't get it: the only thing that is sent is: index2.php?Accept=Send
I would appreciate your help, thank you.
You can receive the value of the select from index2.php, what you have to do is add a name to the select to be able to read the value of the variable, eg:
Then in index2.php you find it like
$_GET['ubicacion']
You can remove the variable from the get of the Form, I would leave only
<form action="index2.php" method="GET">
. Actually I would prefer to pass everything with the POST method, it is safer if in index2.php you are going to do some CRUD.