0

I have a search bar on my unpublished website, and I was hoping that there's some kind of coding that could make it possible to search something that will draw a conclusion from my own website. (As of now, using the search bar takes me to google)

<form id="tfnewsearch" method="get" action="http://www.google.com">
    <input type="text" class="tftextinput" name="q" size="21" maxlength="120"><input type="submit" value="search" class="tfbutton">
</form>
<div class="tfclear"></div>

Any suggestions?

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
Joby
  • 15
  • 1
  • 5
  • 2
    Change the `action` in your form to the url of your site. CSS has absolutely nothing to do with how the search reacts – Pit Feb 23 '16 at 07:46
  • as @pit says, css has nothing to do with the search. you want to search over data stored on database ? – AlainIb Feb 23 '16 at 07:54
  • The form you have now just redirects the search to Google. However, if you don't have the possibility to implement a full search functionality for your own site, and your site can be visited from the internet, you can also imlement [Google's Custom Search Engine](https://cse.google.com/cse/). This lets you use the power of Google's search engine to search explicitly in your site content only. But your site needs to be published for this, otherwise Google cannot index it. – GolezTrol Feb 23 '16 at 07:54
  • If you want to build a search engine ourself, please google a bit more about ways to do this. It's a very broad subject and doesn't fit well into the Q&A format of Stack Overflow. It's also important to know what server side technologies you have available (like PHP) and whether you can install other software (like Lucene or Solr) on your server. – GolezTrol Feb 23 '16 at 08:06
  • 1
    Maybe u could take a look at [How do I implement Search Functionality in a website?](http://stackoverflow.com/questions/34314/how-do-i-implement-search-functionality-in-a-website) – Peyman Mohamadpour Feb 23 '16 at 08:07

2 Answers2

0

You have added the link of google.com that is why you are redirecting to google.

For Your own search engine, you have to make a form for your site and some database queries which will select some data from your database and display the result. replace the google.com with your form url in action tag.

Saleem Jafar
  • 51
  • 5
  • 13
0

It does really depend on how your site is built, and whether it's fully accessible to public.

For example, if it's completely public, you can still use google to search your site by using the Google Custom Search API.

Otherwise, there's no magic potion. You will likely have to write some code to index your documents etc. Many sites achieve this by storing the information in a database and creating a full text index of the site, and then querying the database. But this will require more than just CSS and HTML.

Arunas
  • 1,282
  • 1
  • 11
  • 17
  • Do you know how to do that or a place where I can go to learn ? – Joby Feb 23 '16 at 08:04
  • 1
    @Joby - How to do which? The Google Custom Search API is well documented at the link I provided. For the other option, yes, I know how to do it. It is not something trivial that can be answered in a Stack Overflow question. It's a bit like asking "How do you build a house? I've dug a hole in the ground already, now I need a house..." – Arunas Feb 23 '16 at 08:08
  • @Joby - many things around this you could learn at a place like w3schools.com – Arunas Feb 23 '16 at 08:09