/    Sign up×
Community /Pin to ProfileBookmark

Search box code in html

hello all,
I am looking for some code to add to the one below…what i would like to do is be able to type in a word such as “contact” in a search box click go and have it take me to the contact page…the code below does do that but how can i repeat it with more links and keywords.

so in a nut shell i would like to enter keywords in the search box and have it take me to a specific page

thanks in advance

<form id=”search” action=”http://websitedesignsonly99dollars.weebly.com/contact.html“>
<input name=”contact””about” type=”contact” size=”20″ />
<a href=”http://websitedesignsonly99dollars.weebly.com/contact.html”>Search</a>
</form>

to post a comment
HTML

1 Comments(s)

Copy linkTweet thisAlerts:
@simplypixieNov 24.2012 — This can't be done in just HTML, you need to use PHP. Your form will obviously take you to the contact page as that is where the form data is sent to (specified in your form action). Also, you don't need a link for your Search as this should be a submit button which will then go to the page specified in your form action.

The basics of your form would be

[code=html]<form id="search" method="post" action="search.php">
<input name="keyword" type="text" size="20" />
<input type="submit" name="submit" valeu="Search">
</form>[/code]


And then on search.php you will need to get the value of $_POST['keyword'] and either query a list of pages in a database or in an array and if it exists redirect the person to that page. I cannot give you the code as it depends on how you plan for this to work and if you know PHP.
×

Success!

Help @richardanthony spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...