-1

i've created a very simple php site which has a search box in it and several buttons. Depending on which button i press, i'd like to forward that search to a different page, e. g. google or bing. (So when the button for google is clicked, a google page should appear that shows the correct result, so I go to https://www.google.de/search?q=[input]. That information is stored in a database.)

Question is, would you generally use php to do that kind of stuff (if so, how?) or would you use javascript (using window.location.href)?

thanks in advance

onedude99
  • 11
  • 2
  • For that I would think you could just use simple HTML forms with no javascript nor PHP. Except you say "That information is stored in a database" and I have no idea what you mean. What information? – developerwjk Dec 16 '15 at 19:53
  • well the idea is to have the search engines added by the user. A database stores, which search engines have been added and the the information which link to go to is then being taken from the database. Hope that's clearer... so i wanna make changes to the search engines without having to dive into the html code – onedude99 Dec 16 '15 at 20:19
  • And why would anyone want to use that? A whole website that is nothing but the search functionality of Firefox's search box or probably any other modern browser? Doesn't sound too likely to catch on. – developerwjk Dec 16 '15 at 20:21
  • it's not neccessarily for the public ;) just my own little project and now i'm stuck at a point, at which I'd like to get some opinions on how to actually do it. In such a situation, what would you use? – onedude99 Dec 16 '15 at 20:26
  • 1
    Basically Anthony Thompson's answer but print out the Submit buttons by looping through the results from a database query (done via PHP obviously) for the search engine urls. What more is there to this question than that? – developerwjk Dec 16 '15 at 20:29

1 Answers1

1

You could do something like this:

<form action="https://google.com/search" method="GET">
    <input name="q" type="text"/>
    <input type="submit" value="Submit Google" onclick="this.form.action='https://google.com/search'"/>
    <input type="submit" value="Submit Bing" onclick="this.form.action='https://bing.com/search'"/>
</form>
Antony Thompson
  • 1,608
  • 1
  • 13
  • 22
  • i'm sorry, I haven't been too clear on that. the idea is to make changes to the available databases without having to dive into the html code. Information about which search engines are available will be stored in a mysql database. – onedude99 Dec 16 '15 at 20:21
  • okay, someone just had to open my eyes. Obviously this is the way to go. Thank you :) – onedude99 Dec 16 '15 at 20:31