SitePoint Sponsor

User Tag List

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

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


    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" "">
    <html lang="en" >
    <FORM action="test.php" method="post">
        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">

    The TEST.PHP File

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

    Many thanks,

    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
    152 Post(s)
    0 Thread(s)
    What happens if you also provide a name attribute to the submit button?
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

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

    Many thanks.


Posting Permissions

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