Connecting Tech Pros Worldwide Forums | Help | Site Map

Form Problem

Member
 
Join Date: May 2007
Posts: 58
#1: Mar 4 '08
Hi
I am making a search form that returns the word that the user searched as an experiment, this is the code i am using on index.html
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  
  4.  
  5. <center><form action="welcome.php" method="post">
  6. <input type="text" size="40"  name="name" /></center>
  7.  
  8. <center><input type="submit" value="Search" /></center>
  9. </form>
  10.  
  11. </html>
Then for the second page welcome.php i am using
Expand|Select|Wrap|Line Numbers
  1. <?php echo $_POST["name"]; ?>
What i want is firstly for what the user searches to be in the url for example in a google search for php http://www.google.co.uk/search?hl=en...e+Search&meta= php is in the url how can i make mine so it is /search?PHP for example?

Also how can i make it so on the second page the search box is there?

Thanks

hsriat's Avatar
Expert
 
Join Date: Jan 2008
Location: Bath, UK
Posts: 1,609
#2: Mar 4 '08

re: Form Problem


use get instead of post
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,948
#3: Mar 4 '08

re: Form Problem


Quote:

Originally Posted by hsriat

use get instead of post

Moreso, change
method="post"
to
method="get"
Then on the server side catching script
$_GET['name']
Reply