I need a piece of code that causes the user to put a name on a label and then click the search button, the user is redirected to a page of the name that the user searched for.
//code to redirect
if (isset($_POST["procurar"]))
{
$myPelourinho = $_POST['myPelourinho'];
if ($myPelourinho="Oleiros") {
header('location: oleiros.php');
}
if ($myPelourinho="Sertã") {
header('location: serta.php');
}
if ($myPelourinho="Fundão") {
header('location: fundao.php');
}
if ($myPelourinho="Proença-a-Nova") {
header('location: proenca.php');
}
if ($myPelourinho="Vila Velha de Ródão") {
header('location: vilavelhaderodao.php');
}
if ($myPelourinho="Sarzedas") {
header('location: sarzedas.php');
}
}
<!-- autocomplete and button -->
<form autocomplete="off" method="post" action="server.php" >
<div class="autocomplete" style="width:245px;">
<input id="myInput" type="text" name="myPelourinho" placeholder="Localidade">
</div>
<button type="submit" name="procurar" class="btn btn-default" stlye="width:50px">
<span class="glyphicon glyphicon-search"></span>
</button>
</form>
<!-- autocomplete array list -->
var lista_pelourinhos = ["Fundão", "Proença-a-Nova", "Sarzedas", "Vila Velha de Ródão", "Oleiros", "Sertã"];
autocomplete(document.getElementById("myInput"), lista_pelourinhos);
When I try this, it will always redirect to the last "if" (Sarzedas).