Problem with form Ubmit

Asked

Viewed 28 times

0

Good night,

I have a form search in which it redeems the amount written in input and sends to another page this value to show the results, the problem I’m having and that I use url friendly to submit the value that part is working the problem and that whenever I do form it always adds the id of the url input and the value.

Error example

http://sabeonde.pt/locais/pesquisa/?pesquisa=teste

When she should be like this:

http://sabeonde.pt/locais/pesquisa/teste

Code

 <form action="locais/pesquisa/<?= $_REQUEST['pesquisa'] ?>"/>
          <div style="margin-left:150px;">
              <div style="float:left; width:500px;"><input id="pesquisa" name="pesquisa" type="text" placeholder="Restaurantes, bares, hotéis..." /></div>
              <div style="float:left; margin-left:5px;"><input type="submit" value="Pesquisar" /></div>
          </div> 
        </form>

How can I fix this ?

  • 1

    I think the problem is the same as your previous question, which has the problem of not having touched on the subject of whether you are using the GET method in the form or not. If you use GET you can’t get ?pesquisa= URL without redirect (which would be bad too, generating an unnecessary request).

  • So that means there’s no way to solve the problem ?

  • Either you use friendly URL, or you use GET. (or some scam, which I think is worse). But look at the comments on the other question, we are discussing the subject in the answer from there. If you switch to POST, the search term disappears and the URL is friendly, but there is no way to make Bookmark. What you can do, as an intermediate solution, is accept the friendly form, but accept the form with ? q= also. This way you generate the friendly links when you need them, but you can use GET. Or make a redirect, which makes everything friendly but costs 1 more request.

  • 1

    Likely the solution depends on improving the previous question Add a fixed word to a friendly URL instead of making a new.

  • If you want Submit to send input through the URL http://sabeonde.pt/locais/pesquisa/{input}, you can make an event by jQuery to redirect the form with input at the end of the URL.

  • @Bacco, I think his problem is aesthetic, the /?q=input does not affect the friendly url - at least not with my settings

  • 2

    @Papacharlie I considered this, the problem is we have a paradox here: if it is not GET, as he commented, there is no way to appear a ?q= nowhere. Only if it’s a POST, what the person typed will only be in the body of the request, accessible with $_POST, and will not appear in the friendly URL, you know? I believe the question is mixing what the author wants to do with his actual code. He said he wants a POST, but the form as it is in the question by default is GET. Note: I like POST because of the aesthetics too, but the problem is it doesn’t give Bookmark. See my comment on his other question.

  • 1

    @Bacco, He wants to make Post turn Get and Get turn Post :) He could receive via Post and redirect the new formatted URL, but between us...

  • 1

    @Papacharlie see the comments here (in the reply too) if you are curious: http://answall.com/questions/54787/ ... I even thought of manipulating history after the POST, but I think it is somewhat patched. And this research stuff the less complicated, the better. Mainly because several browsers allow you to do a series of custom searches on sites of your preference (at least Opera and Vivaldi are very practical in this).

  • It’s the same question he opened in another way, explaining everything very confusing... Now I’m confused...I need a psychiatrist;;

  • this done resolved

Show 6 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.