2
Good night,
I’m doing some research and I’m having a problem passing the value that is written on input
to another page where the result will be displayed.
Example Url I’m trying to pass values
http://exemplo.com/locais/pesquisa?q=bares
File . htaccess
RewriteRule ^locais/([a-zA-Z-0-9-_]+)$ index.php?controller=pesquisa?q=$1
But always returns me the name search and not what I typed in input
Form
<form method="post" id="pesquisa_home" name="pesquisa_home" action="locais/pesquisa/<?= $_POST['valor_pesquisa'] ?>" >
<div style="margin-left:150px;">
<div style="float:left; width:500px;"><input id="valor_pesquisa" name="valor_pesquisa" type="text" placeholder="Restaurantes, bares, hotéis..." /></div>
<div style="float:left; margin-left:5px;"><input type="submit" value="Pesquisar" /></div>
</div>
</form>
use the url like this: http://exemplo.com/locais/bars
– Daniel Omine
but you can’t use it that way ?
– César Sousa
is possible but you need to change the rewriterule rule to ignore the word search.. I preferred not to comment on this because I suggest keeping the url as short as possible.. The word "pequisa" becomes unnecessary because it is only the name of the parameter. But if you have a specific reason, then just include the term in the rule
– Daniel Omine
But you can’t pass the folder q as in the url it looks like http://exemplo.com/locais/search?q=bars
– César Sousa
but what’s the point of sending the parameter this way ? After all you want friendly url or normal url ?
– Daniel Omine
as I commented above, it is possible to do this... I think you want to do it is not url friendly, it is merely a "routing".
– Daniel Omine
You’re right I’m sorry at this hour and programming day and night I’m out of my mind
– César Sousa
I want and url friendly
– César Sousa
If the term research is fixed, just need to put in your rule.
– Papa Charlie
take the right search ? and leave only local/bars ?
– César Sousa
would look like this: Rewriterule local/search/([a-za-Z-0-9-_]+)? index.php? controller=search? q=$1
– Daniel Omine
then you access the link like this: address.do.site/places/search/bars
– Daniel Omine
but now when searching it always adds the ? in the url so breaks the url
– César Sousa