SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: form submission

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    form submission

    I have a form like this :
    Code HTML4Strict:
    <form action="index.php" method="get">
    <input type="hidden" id="task" name="task" value="<?=$searchType?>" />
    <input type="hidden" name="ct" value=""/>
    <input type="hidden" name="option" value="com_classifiedsearch" />

    Can i embed the staic values of some of the form fields in the form action like this?
    Code HTML4Strict:
    <form action="index.php?option=com_classifiedsearch" method="get">
    [INDENT]<input type="hidden" id="task" name="task" value="<?=$searchType?>" />
    <input type="hidden" name="ct" value=""/>
    <input type="hidden" name="option" value="com_classifiedsearch" />[/INDENT]

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually I want to change the form to something like this:
    Code HTML:
    <form action="index.php?option=com_classifiedsearch" method="get"><input type="hidden" id="task" name="task" value="<?=$searchType?>" />
    <input type="hidden" name="ct" value=""/>
    </form>

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2009
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    if (something) 
        {$a = '?option=com_classifiedsearch';  }
    
    
    print <<<_embed_
    
    
    <form action="index.php$a" method="get">
    .... 
    
    _embed

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2009
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry I didn't mean to post that, the WYSIWG thing freaked out on me, I didn't realize it had submitted, and you only have 60 seconds to correct errors.

    I believe you can do what you asked about.

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But I have a feeling that the query string in the form action is being wiped out by the form fields when the form is submitted?

  6. #6
    SitePoint Enthusiast
    Join Date
    Aug 2009
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now that you mention that... I believe that is right.

    Ideally, you should just submit data via POST or GET, and not both at the same time.

    You could do something like this

    Code:
    <form action="index.php" . . . . 
    <input value="com_classifiedsearch" type="hidden" name="blah" ..... /> ....
    and then for index.php
    Code:
    if (($_SERVER['REQUEST_METHOD'] == 'POST') 
              && ($_POST['blah'] == "com_classifiedsearch"))
              {do something}

  7. #7
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    982
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You cannot have a query string in your form action if you are submitted a get, but you can if you are submitting a post.

    Works:
    Code:
    <form action="index.php?this=that" method="post">
    Breaks:
    Code:
    <form action="index.php?this=that" method="get">
    MySQL v5.1.58
    PHP v5.3.6

  8. #8
    SitePoint Enthusiast
    Join Date
    Aug 2009
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If BrandonK says it, that's good enough for me.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •