The search box is a very important part of any website which helps in making the website user friendly. In this tutorial, we will learn how to create a Google search input box on the website using PHP programming. Google search box can be easily created by Google search query URL and PHP. When a user enters the keywords in the Google search input box and clicks on the search button then redirects on the Google website and displays the related content links to the keywords, website. If you create Google search on your PHP website, it reduces the load on the website all related posts are displayed on the first page of Google. Along with user keywords, we can define the website name or website URL with search keywords.
How to create Google Search box in PHP –
To create a Google search system or Google search input box in PHP, we first create an HTML input box.
The HTML input box is created to retrieve the value from the users by which the value taken is used with the Google search query. The HTML input box is create inside the HTML form . Along with the input box, A button is also created. By clicking on this button, keywords are searched on the Google website.
Let’s create a form with an input box and a submit button.
Google Search Box in HTML –
In the form above, we have an input box and which works like a Google search box, by clicking on a button, the user gets redirected to the live Google search. You must have noticed that some CSS classes have been used here, but CSS classes also have to be created
We use CSS classes to design the Google search box. Let's create CSS classes and design the HTML form input box, button.
Designing Google Search box -
What this Google search query URL-
, Google search query URL is used to search for keywords on Google search engine. All search engines along with Google have their own search query URLs.
Google Search Query URL
By using the Google search query, we create a search input box using PHP programming
Google search box in PHP -
To create the Google search box on the PHP website, we create PHP scripts.
1. HTML form (input box + button).
2. HTML Form Designing.
3. PHP Scripts - User enters the values into the input box and the PHP post method handles those values. As you know, the Post method is known as a form handling method. The values are stored in a variable by the POST method . We use that values with Google search query URL and website name ( you can use website URL also ).
$base="Techno Smarter"; // Change base here
$search_URL="http://www.google.com/search?q="; // Google Search Query URL
header("location: ".$search_URL.$keywords.' '.$base );
In the PHP scripts above, First, we created two variables, We stored the website name in the first variable and stored the Google search query URL in the second variable.
We added equals to sign (=) with Google search query URL. If condition is used to create form submit on the button. The form cannot be submitted without submit button pressed. We have used the header function and their values.
- Google search query URL ( with = sign )
- Keywords – Values from user
- Base – Website name or website URL.
In this way, you can create a Google search system or input box on the PHP website.
Integrate PayPal payment gateway in PHP with MYSQL database | PHP scripts
Paypal Payment form in PHP website with MYSQL database | International Payments
Payment form by PayUmoney gateway with GST invoice,email | PHP software