Create google search box using HTML form
So, I'm trying to insert a search form on my website that will redirect the user with their request to Google Search.
I used to do this using:
<form role="search" method="get" id="searchform" class="searchform" action="http://www.google.co.uk/search?hl=en-GB&source=hp&q=">
<div id="gform">
<label class="screen-reader-text" for="s"></label>
<input type="text" value="" name="s" id="s">
<input type="submit" class="btn fa-input" value="" style="font-family: FontAwesome;">
</div>
</form>
However, this no longer works. I am guessing this is because Google changed the search url, but I cannot reproduce this effect using the current Google url.
Any idea how to fix this?
+4
source to share
2 answers
Hi everyone, I think I solved the problem myself
<div id="gform">
<label class="screen-reader-text" for="s"></label>
<input type="text" value="" name="q" id="s">
<input type="submit" class="btn fa-input" value="" style="font-family: FontAwesome;">
</div>
The key point that solved my problem is
name="q"
. This is what you need for google search to work; this is mainly because google expects
q
as a name
+2
source to share