SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Oct 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question HTML Form: Works the GET, but not POST.

    Hi,

    I have a form which quite happily works locally on my laptop in both WAMP & XAMPP.

    When I use method="post" the values get transfered ok, and likewise the same when I use method="get".

    However, when I run the same form on a Windows 2008 Server it works fine with the method="get" (As expected, I can see the values in the URL), but fails to transfer any values when using method="post" i.e.

    Wamp = Both "post" & "get" work without a problem.

    XAMPP = Both "post" & "get" work without a problem.

    Server = Only "get" works. "Post" fails to tranfer any values.

    The fact that the form works ok on my laptop when using WAMP or XAMPP leads me to suspect that the Windows Server needs to be configured to allow the use of "post" in forms, or at least to allow form values to be passed i.e. like global variables.

    However, I'm not sure if this thinking is correct or whether I simply need to enable something on the server.

    VAR_DUMP ( $_POST ); confirms that the array is empty

    The FORM:

    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html lang="en" >
    <head>
    </head>
    <body>
    
    
    <FORM action="test.php" method="post">
        <P>
        First name: <INPUT type="text" name="firstname"><BR>
        Last name: <INPUT type="text" name="lastname"><BR>
        email: <INPUT type="text" name="email"><BR>
        <INPUT type="radio" name="sex" value="Male"> Male<BR>
        <INPUT type="radio" name="sex" value="Female"> Female<BR>
        <INPUT type="submit" value="Send"> <INPUT type="reset">
        </P>
     </FORM>
    
    </body></html>

    The TEST.PHP File

    PHP Code:
    <?php 
    echo "POST: ";
    var_dump$_POST ); 
    echo 
    "GET: ";
    var_dump$_GET );
    ?>
    Any guru out there know the answer?

    Many thanks,

    Pete
    Last edited by cpradio; Oct 31, 2013 at 18:03.

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,233
    Mentioned
    154 Post(s)
    Tagged
    0 Thread(s)
    What happens if you also provide a name attribute to the submit button?

  3. #3
    SitePoint Member
    Join Date
    Oct 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It works.... cpradio - you are a genius mate :-)

    Many thanks.


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
  •