$_GET problem

Discussion in 'PHP' started by lanmonkey, Apr 24, 2008.

  1. #1
    I have a form containing the following:

    <form action="main.php?page=home" method="post">by search: <input name="search" type="text" /> <input type="submit" value="Go" /></form>
    Code (markup):
    when someone uses this form I want to the url to be something like:
    www.mydomain.com/main.php?page=home&seach=<whaever the user typed>

    what I am getting is:
    www.mydomain.com/main.php?seach=<whaever the user typed>
    Code (markup):
    .. its losing the “?page=home” bit

    Any way around this?
     
    lanmonkey, Apr 24, 2008 IP
  2. pubdomainshost.com

    pubdomainshost.com Peon

    Messages:
    1,277
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you may append the string page=home when you process the string in main.php

    FORM action is NOT used to pass arguments, it just indicates which page is going to be invoked for processing the form, and thus drops anything after the page name .

    An alternative would be to use <input type=hidden name=page value=home> within your form.

    HTH
     
    pubdomainshost.com, Apr 24, 2008 IP
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    Change:

    <form action="main.php?page=home" method="post">

    To:

    <form action="main.php" method="get">

    and add the page as a hidden tag.

    Peace,
     
    Barti1987, Apr 24, 2008 IP
  4. lanmonkey

    lanmonkey Active Member

    Messages:
    549
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    60
    #4
    fantastic, thanks guys
     
    lanmonkey, Apr 24, 2008 IP
  5. phpl33t

    phpl33t Banned

    Messages:
    456
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #5
    
    <form method="POST" action="main.php">
         <input type="hidden" name="page" value="home">
         <input type="submit" value="Go!">
    </form>
    
    HTML:
     
    phpl33t, Apr 24, 2008 IP