lisovaccaro
lisovaccaro

Reputation: 33956

Simple search form that redirects to ?s=searched terms

I want to make a simple form that redirects the user to "?=whateverhetypes". I'm sure it's easy but I just grasped the basics of sending variables through the url and I don't know how.

I suppose this would be the form:

<form>
<input type="text" name="search">
<input type="submit">
</form>

What's the shortest way to do it? Thakns

Upvotes: 0

Views: 58

Answers (1)

Treffynnon
Treffynnon

Reputation: 21553

<form method="get" action="">
    <input type="text" name="s" />
    <input type="submit" />
</form>

Set action to be the URL of the file you would like the form to redirect to (for example action="/url/script.php"). Leave it blank to submit onto the current page.

Note how I renamed your text field to be just s so that when the form is submitted it will go to /url/script.php?s=searched terms like you have asked in the title of your question.

Upvotes: 1

Related Questions