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>
|