Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Appending search term to URL in results
Old 02-25-2008, 08:54 AM Appending search term to URL in results
Defies a Status

Posts: 1,606
Trades: 0
This form:

Quote:
print "<form action='index.php?search=' method='post'>";
print "<input type='text' name='searchterm' length='10'>";
print "<input type='submit' name='select' value='search'>";
print "</form>";
Works and produce the correct result but the url looks like this and does not contain the search query.

mydomain.com/index.php?search=

I do plan to use modrewrite to modify the displayed results.

TIA
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-25-2008, 10:47 AM Re: Appending search term to URL in results
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
OK you need to learn about GET and POST. POST doesn't show up in the browser string. GET does.
I don't get why you'd have said form in PHP.
PHP Code:
<?php $search $_GET['search'];
echo 
$search;?>
<form action="index.php" method="get">
<input type="text" name="search" length="10">
<input type="submit" value="Search"></form>
OK now to explain line by line, first off, this is a snippet. You'll of course need the basic html stuff around it. Also know that it won't validate because you need to have something around the text box and submit button (such as <p> around them both).
The first line assings $search to the value of what is carried in the URL as the search term. If the url is http://example.com/index.php?search=foo then $search will be foo. The second line outputs the content of $search to the screen, so foo will show up. The third line starts the form. It tells it what page to go to, index.php, and whether to post it or to send it in the URL. The method you're using is GET so it goes to the URL. The next line creates a text box that is ten characters wide, but can hold as many characters as the user wishes. You may want to put maxlength="#" in there too. The name is what's important, that's what the post/get name is. The last line creates the submit button, it doesn't need a name, and it'll have the word Submit on it.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Reply     « Reply to Appending search term to URL in results
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26872 seconds with 12 queries