Olivier Grech Olivier Grech - 2 months ago 6
HTML Question

Google search bar is redirecting me to www.google.com without launching the research

I'm trying to add a Google search bar on my personnal website (not for searching only on my website but for searching on the internet).

<form method="get" action="https://google.com/search" target="_blank">
<input type="text" placeholder="Google" class="search">
</form>


However, when I'm filling the search bar and pressing Enter, I'm getting redirected to www.google.com with an empty search bar.

You can see a working example of what I'm trying to do here: https://startpages.github.io/startpages/startpage-bamboocza/ (hover your mouse over the big picture).

I tried adding a submit button but I'm getting the same issue. I'm not sure where the issue could came from since the HTML on my website is almsot a copy-paste of the one from the working example. Any help?

Answer

In the input tag, put an attribute called name. For example:

<input type="text" placeholder="Google" class="search" name='q'>

That should fix your problem.

Comments