?
Solved

Send search query in URL, eg. ...search.php?query=blah

Posted on 2008-11-02
2
Medium Priority
?
430 Views
Last Modified: 2012-08-13
Hi,

I'm currently using the attached code to search a certain page depending on the dropdown chosen, at present, the code sends the user to the search results page with the query hidden from the url. His it possible for someone to modify this code so that the search term is shown in the URL?

EG.

The user searches for "test", so the url they are returned to would be "search.php?q=test".

Note: The javascript below sets the url they are returned to depending on what dropdown box is chosen.

Thanks,
Paul
<script type="text/javascript"><!--
function setAction(theForm){
  theForm.action = theForm.evt.value+theForm.trigger.value+".php";
}
--></script>
 
<form name='search' id='theSearchForm' method='post' onSubmit='setAction(this)' >
<input type='hidden' name='trigger' value='search_caws' >
<input type='text' name='search' size=25 maxlength=25 >
<select name='evt'>
<option value='http://cawsearch.com/impact/'>TNA iMPACT</option>
<option value='http://cawsearch.com/svr2008/'>Smackdown vs RAW 2008</option>
<option value='http://cawsearch.com/firepro/'>Fire Pro Wrestling Returns</option>
<option value='http://cawsearch.com/dor2/'>Day Of Reckoning 2</option>
<option value='http://cawsearch.com/wm21/'>WrestleMania 21</option>
</select>
<input type='Submit' name='search_caws' value='CAWSearch' onClick='this.form.trigger.value=this.name;' >
<input type='Submit' name='lucky' value='I&#39m Feeling Lucky' onClick='this.form.trigger.value=this.name;' >
</form>

Open in new window

0
Comment
Question by:m0tSiE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Accepted Solution

by:
AielloJ earned 2000 total points
ID: 22862336
You can change your form to the GET method by adding the "action" property to the URL and the php code to echo the search text (which I'm assuming is in the text field named 'search'.  I have a question as to why you are changing something that is working?  GET methods of posting reveal how your website is able to be controlled whereas a POST method does not.  A user can create their own URL's in the browser and possibly bypass your form code and any checking it may be doing.

<form name='search' action="search.php?q=<?php echo this.search; ?>" method="get"  id='theSearchForm">
0
 

Author Closing Comment

by:m0tSiE
ID: 31512459
Cheers :D
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question