Creating a Google search box using HTML form - html

So I am trying to insert a search form on my website that will redirect the user with their query to Google Search.
I used to be able 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'm guessing this is because Google have changed the search URL, but I am unable to replicate this effect by using Google's current URL.
Any idea how to fix this?

Hi all it seems I have 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 here that resolved my issue is name="q". This is what you need to make google search work; basically this is because google expects q as the name

This snippet creates a simple google search box
<form action="http://www.google.com/search" method="get">
<input type="text" name="q"/>
<input type="submit" value="search" />
</form>

Related

tbm image search filter in image search query

I am trying to mirror the google image search.
so far I know that q is the name for the actual google search (or query).
On the address it will look: www.google.com/search?q=parrot
but on the google image search also appears /search?q=parrot&tbm=ish
I looked and found out that tbm stands for "to be match" and is a filter and I guess is the filter to match the images... but I don't have a clue how to put inside my html code.
So far I have done this:
<form action="https://www.google.com/search" class="form">
<input type="text" name="q" class="search_bar"
<input type="submit" value="Search" class="submit">
</form>
How do I add the tbm filter? Thanks!
You can add a hidden input field and set the value of it.
example
<form action="https://www.google.com/search" class="form">
<input type="text" name="q" class="search_bar">
<input type="hidden" name="tbm" value="ish">
<input type="submit" value="Search" class="submit">
</form>

Displaying images on demand

I need to make sure that when I enter a request, I get pictures (in google). There is such a line of html code:
<div>
<form action="https://www.google.com/imghp">
<input type="text" name="q">
<input type="submit" value="Google Image Search">
</form>
</div>
But when you enter a request, it simply throws it to the page with a request, where you need to PRESS the search button. Is there any way to make the pictures of my request appear?
For Searching in Google Images, you can use this HTML code:
<form method="GET" action="http://images.google.com/images">
<input type="text" name="q">
<input type="submit" value="Search Google Images">
</form>

How do I create a link to google image search via HTML form?

Trying to make Google Image Search Clone using HTML form where after entering text in the search field it will take you directly to Google Image search results page.
Here is the code that I am using:
<body>
<form action="https://google.com/search">
<input type="text" name="q">
<input type="submit" value="Google Search">
</form>
</body>
It will take to normal google search, how do I change it to google image search result page?
You have to change the action, as such:
<form method="get" action="http://images.google.com/images">
<input type="text" name="q" />
<input type="submit" value="Google Search" />
</form>
Google image search link is of the following format
https://www.google.com/search?q=```query```&tbm=isch
Each of the parameters, q and tbm, requires an input tag but tbm does not require any user input.
'GET_parameter_name=value' for every input tag before submit button is appended by '&'.
<form action="https://www.google.com/search">
<input type="text" name="q" id="box">
<input type="hidden" name="tbm" value="isch">
<input type="submit" value="Image Search" >
</form>
Source:
https://stenevang.wordpress.com/2013/02/22/google-advanced-power-search-url-request-parameters/
https://www.xul.fr/javascript/parameters.php

I want to append my own text beforehand to a google search in html

This explains how to add a search bar in html: Creating a Google search box using HTML form
What if we want to previously append some of our own text to the search? for example,
when I input a text into the search, google should search for "hotels at input-text"
This creates the search bar:
<form role="search" method="get" id="searchform" class="searchform" action="http://www.google.com/search?hl=en-GB&source=hp&+q=">
<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>
</form>

Form dosnt go to action address

I have a problem. I have two forms in a web page that are different action but one of my form don't work.
<form name="loginform" id="loginform" action="./loginAction.php" method="GET" class="login-form">
<input type="hidden" name="action" value="login">
<div class="form-group">
<label class="sr-only" for="form-user">Username or Email</label>
<input type="text" name="uname" placeholder="Username or Email..." class="form-user form-control" id="form-user" required>
</div>
<div class="form-group">
<label class="sr-only" for="form-pass">Password</label>
<input type="password" name="upass" placeholder="Password..." class="form-pass form-control" id="form-pass" required>
</div>
<button name="loginBtn" value="login" type="submit" class="btn">Sign in!</button>
</form>
even in submit dosn't redirect to action page
you can see in this url
There is no problem in you html code as well as javascript code.
Its your server code which is redirecting back to the login page . As you are using get the data should be visible in the url. When the form is submited the data cleans because its redirected to the login page. SO if you provide the server code we can have a look to it
From a first look i think if you want to submit data with a form you need to set method="post"