Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: $_POST empty in PHP

  1. #1
    Join Date
    Aug 2008
    Location
    East England
    Posts
    50

    Default $_POST empty in PHP

    I'm using openSUSE 10.3 with apache 2 and php 5 from the main/update repos. A fairly standard configuration, with some caveats below.

    I have a form (in xhtml 1.1) with method "post" action "process.php" and enctype "multipart/form-data" (although the type doesn't seem to matter, I've tried others).

    When accessed from process.php, loaded following form submission, $_POST is empty. Passing it to print_r results in only "Array ( )".

    Firebug shows this:
    Content-Type: multipart/form-data; boundary=---------------------------18241582601317123334195430822

    4

    Content-Length: 63

    -----------------------------182415826013171233341954308224--
    My access log says this:
    127.0.0.1 - - [22/Aug/2008:20:59:27 +0100] "POST /GLUserFed/process.php HTTP/1.1" 200 2366 "http://localhost/GLUserFed/articulate.php" "Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0) Gecko/2008061600 SUSE/3.0-1.1 Firefox/3.0"
    I tried inserting into (and have since removed from) my server directory configuration:
    Code:
    <Limit POST>
    order allow,deny
    allow from all
    </Limit>
    Despite configuring the server to populate the html raw data or whatever it was, its related PHP variable was also empty. GET also doesn't work. I think I tried a couple of other things, but I'm at a loss to remember what. All this is done on a single laptop, haven't tried anything from a remote host.

    Frankly, I am at a loss. I have little doubt that I am missing something obvious but, since I am missing it, I'm hoping someone here can illuminate the matter for me.

  2. #2
    ab@novell.com NNTP User

    Default Re: $_POST empty in PHP

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    If you're using Firefox perhaps install the HTTP Headers
    extension/plug-in/add-on and make sure your browser is properly sending
    all you think it should. To test GET you can append anything you want
    to your URL and you should see that in $_GET if you look at it with PHP.
    I assume you've verified PHP works at some level since you mentioned
    making a form in static HTML as a test....

    Good luck.





    Solar Granulation wrote:
    > I'm using openSUSE 10.3 with apache 2 and php 5 from the main/update
    > repos. A fairly standard configuration, with some caveats below.
    >
    > I have a form (in xhtml 1.1) with method "post" action "process.php"
    > and enctype "multipart/form-data" (although the type doesn't seem to
    > matter, I've tried others).
    >
    > When accessed from process.php, loaded following form submission,
    > $_POST is empty. Passing it to print_r results in only "Array ( )".
    >
    > Firebug shows this:
    >> Content-Type: multipart/form-data;
    >> boundary=---------------------------18241582601317123334195430822
    >>
    >> 4
    >>
    >> Content-Length: 63
    >>
    >> -----------------------------182415826013171233341954308224--

    >
    > My access log says this:
    >> 127.0.0.1 - - [22/Aug/2008:20:59:27 +0100] "POST /GLUserFed/process.php
    >> HTTP/1.1" 200 2366 "http://localhost/GLUserFed/articulate.php"
    >> "Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0) Gecko/2008061600
    >> SUSE/3.0-1.1 Firefox/3.0"

    >
    > I tried inserting into (and have since removed from) my server
    > directory configuration:
    >
    > Code:
    > --------------------
    > <Limit POST>
    > order allow,deny
    > allow from all
    > </Limit>
    > --------------------
    >
    >
    > Despite configuring the server to populate the html raw data or
    > whatever it was, its related PHP variable was also empty. GET also
    > doesn't work. I think I tried a couple of other things, but I'm at a
    > loss to remember what. All this is done on a single laptop, haven't
    > tried anything from a remote host.
    >
    > Frankly, I am at a loss. I have little doubt that I am missing
    > something -obvious- but, since I am missing it, I'm hoping someone here
    > can illuminate the matter for me.
    >
    >

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFIrxty3s42bA80+9kRAn3AAJkBX6PRYgKsNpZwjQK0ETJ9U8W9vwCghNjR
    s+3QH5DWoEocujtE7MOD6v4=
    =cxaK
    -----END PGP SIGNATURE-----

  3. #3
    Join Date
    Aug 2008
    Location
    East England
    Posts
    50

    Default Re: $_POST empty in PHP

    Thanks for the suggestion, please have a look at the result...

    http://localhost/GLUserFed/process.php

    POST /GLUserFed/process.php HTTP/1.1
    Host: localhost
    User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0) Gecko/2008061600 SUSE/3.0-1.1 Firefox/3.0
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-gb,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    Referer: http://localhost/GLUserFed/articulate.php
    Content-Type: multipart/form-data; boundary=---------------------------168187704412881316131903039127
    Content-Length: 63
    -----------------------------168187704412881316131903039127--

    HTTP/1.x 200 OK
    Date: Fri, 22 Aug 2008 20:37:13 GMT
    Server: Apache/2.2.4 (Linux/SUSE)
    X-Powered-By: PHP/5.2.6
    Content-Length: 2366
    Keep-Alive: timeout=15, max=100
    Connection: Keep-Alive
    Content-Type: text/html
    ----------------------------------------------------------
    HELP!

    Also, I failed to notice before (goodness knows how) that if using get... nothing is appended to the URL. Same goes for the other browsers I have installed. I'm...... confused.

    I almost forgot to say that, yes, PHP (apart from in this instance) is working very nicely.

  4. #4
    ab@novell.com NNTP User

    Default Re: $_POST empty in PHP

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    If I didn't know better I'd say your browser wasn't sending the data.

    - From a login to gmail:

    POST /accounts/ServiceLoginAuth?service=mail HTTP/1.1
    Host: www.google.com
    User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US;
    rv:1.8.1.14) Gecko/20080410 SUSE/2.0.0.14-0.4 Firefox/2.0.0.14
    Accept:
    text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    Referer:
    https://www.google.com/accounts/Serv...Dhtml%26zy%3Dl
    &bsv=1k96igf4806cy&ltmpl=default&ltmplcache=2
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 189
    ltmpl=default&ltmplcache=2&continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3F&service=mail&rm=false&ltmpl=default&ltmpl=default&Email=testuser&Passwd=testpas
    s&rmShown=1&signIn=Sign+in&asts=

    Good luck.





    Solar Granulation wrote:
    > Thanks for the suggestion, please have a look at the result...
    >
    >> http://localhost/GLUserFed/process.php
    >>
    >> POST /GLUserFed/process.php HTTP/1.1
    >> Host: localhost
    >> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0)
    >> Gecko/2008061600 SUSE/3.0-1.1 Firefox/3.0
    >> Accept:
    >> text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    >> Accept-Language: en-gb,en;q=0.5
    >> Accept-Encoding: gzip,deflate
    >> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    >> Keep-Alive: 300
    >> Connection: keep-alive
    >> Referer: http://localhost/GLUserFed/articulate.php
    >> Content-Type: multipart/form-data;
    >> boundary=---------------------------168187704412881316131903039127
    >> Content-Length: 63
    >> -----------------------------168187704412881316131903039127--
    >>
    >> HTTP/1.x 200 OK
    >> Date: Fri, 22 Aug 2008 20:37:13 GMT
    >> Server: Apache/2.2.4 (Linux/SUSE)
    >> X-Powered-By: PHP/5.2.6
    >> Content-Length: 2366
    >> Keep-Alive: timeout=15, max=100
    >> Connection: Keep-Alive
    >> Content-Type: text/html
    >> ----------------------------------------------------------

    >
    > HELP!
    >
    > Also, I failed to notice before (goodness knows how) that if using
    > get... nothing is appended to the URL. Same goes for the other browsers
    > I have installed. I'm...... confused.
    >
    >

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFIryQi3s42bA80+9kRAgTbAJwKLQZpAFQuoGSmnAk5c0JkGPpb5wCeOW3T
    ABuxqVk/ovWKjYMnO43MWoI=
    =FeKa
    -----END PGP SIGNATURE-----

  5. #5
    Join Date
    Aug 2008
    Location
    East England
    Posts
    50

    Default Re: $_POST empty in PHP

    That's something I'm finding very odd. Obviously I have no trouble submitting form data to this forum, or other forums etc. But when I try to submit my own form to my own server on my own laptop... nothing.

    Why, why would that be?

    I feel like I'm head butting a wall.

  6. #6
    ab@novell.com NNTP User

    Default Re: $_POST empty in PHP

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    First suspicion.... a problem with the HTML. Care to paste the entire
    form you're using?

    Good luck.





    Solar Granulation wrote:
    > That's something I'm finding very odd. Obviously I have no trouble
    > submitting form data to this forum, or other forums etc. But when I try
    > to submit my own form to my own server on my own laptop... nothing.
    >
    > Why, why would that be?
    >
    > I feel like I'm head butting a wall.
    >
    >

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFIry1o3s42bA80+9kRAtPVAJ9YArH3efdu1wYETYjlPj3tE2zqKgCffrur
    KO1LhK+GXiZDzHbkVzYerhk=
    =NP2A
    -----END PGP SIGNATURE-----

  7. #7
    Join Date
    Aug 2008
    Location
    East England
    Posts
    50

    Default Re: $_POST empty in PHP

    This is the non-plain html version. I thought, since this is the important one, it only made sense. I considered leaving out unrelated bits, but then I thought I might as well post the lot... so here it comes!

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/2001/REC-xhtml11-20010531/DTD/xhtml11-flat.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB">
    <head>
    	<title>GNU/Linux User Federation - Submit Article</title>
    	<meta http-equiv="Content-Type" content="application/xhtml+xml;charset=utf-8" />
    	<meta http-equiv="Content-Style-Type" content="text/css" />
    	<meta name="author" content="Matthew Ayres solar.granulation@gmail.com" />
    	<meta name="description" content="The GNU/Linux User Federation - A project to unite the communities." />
    	<meta name="keywords" content="GNU/Linux, Linux, GLUF, distro, unity, harmony, user community, Linux users" />
    	<link rel="stylesheet" type="text/css" href="./gluf.css" />
    
    	<script type="text/javascript" src="./targetExternals.js"></script>
    	<!--[if IE]>
    	<meta http-equiv="refresh" content="0;URL=./notforie.html">
    	<![endif] -->
    	<link rel="stylesheet" type="text/css" href="./SolarsPopup.css" />
    	<script type="text/javascript" src="./SolarsPopup.js"></script>
    	<script type="text/javascript" src="./richSelections.js"></script>
    	<script type="text/javascript">
    	var richText = "articleContent";
    	</script>
    </head>
    
    <body>
    
    <div><img src="./images/trcorner.png" style="margin: 0; vertical-align: top; float: right;" width="20" height="20" alt="" /><!-- The top right corner --></div>
    
    <div id="header"><img src="./images/tlcorner.png" style="margin: 0; vertical-align: top;" width="20" height="20" alt="" />
    <a rel="internal" href="./"><img src="./images/logo.png" id="logo" height="150" width="150" alt="The GNU/Linux User Federation" /></a>
    <p id="quote">&ldquo;I could have made money this way, and perhaps amused myself writing code. But I knew that at the end of my career, I would look back on years of building walls to divide people, and feel I had spent my life making the world a worse place.&rdquo; &mdash;&nbsp;Richard M. Stallman</p>
    	<div id="menubar">
    	<ul>
    		<li><a rel="internal" href="./">Home</a></li>
    
    		<li class="bl"><a rel="internal" href="./membership.html">Membership and Participation</a></li>
    		<li class="bl"><a rel="internal" href="./articles.php">Member articles</a></li>
    		<li class="bl"><a rel="internal" href="./common.html">Common ground</a></li>
    		<li class="bl"><a rel="internal" href="./features.html">Feature origins</a></li>
    		<li class="bl"><a rel="internal" href="./abtgluf.html">About GL&Uuml;F</a></li>
    		<li class="bl"><a rel="internal" href="http://forum.gluf.org.uk/" title="GL&Uuml;F Forum">GLUFF</a></li>
    
    	</ul>
    	</div>
    </div>
    <form id="articulate" action="./process.php" method="post" enctype="multipart/form-data">
    <div id="content" style="z-index: 1;">
    <h1>Submit Article</h1>
    <fieldset style="border: 0;">
    <p>Please be aware that your article will not immediately appear on the Member Articles page.&nbsp; As part of our anti-spam and anti-abuse procedures we manually review every submission for approval.</p>
    <div style="margin-left: 4%; width: 95.7%; font-size: 0.8em;">
    
    <input id="articleTitle" type="text" class="text" title="Title" /><br />
    
    <div id="rich" style="margin: 0; padding: 0;">
    <input onclick="imagePop(richText);" type="button" value="Insert image" /><input onclick="linkPop(richText);" type="button" value="Insert hyperlink" />
    <input onclick="wrapSelection(richText,'','');" type="button" value="Bold" /><input onclick="wrapSelection(richText,'','');" type="button" value="Italic" /><input onclick="wrapSelection(richText,'','');" type="button" value="Underline" />
    <input onclick="wrapSelection(richText,'[h]','[/h]');" type="button" value="Section heading" /><input onclick="wrapSelection(richText,'[sh]','[/sh]');" type="button" value="Subsection heading" />
    <textarea id="articleContent" rows="20" cols="100" style="height: 20em;" title="Content"></textarea>
    <table style="width: 100%">
    	<tr>
    		<td style="width: 10%; text-align: right;">Screen alias:</td>
    		<td style="width: 34%;"><input type="text" class="text" id="alias" /></td>
    		<td style="width: 7%; text-align: right;">e-mail:</td>
    
    		<td style="width: 34%;"><input type="text" class="text" id="email" /></td>
    		<td style="width: 12%; text-align: right;">Publish e-mail:</td>
    		<td style="width: 3%;"><input type="checkbox" id="use" /></td>
    	</tr>
    </table>
    </div>
    <input type="submit" value="Submit" style="font-size:2em;" />
    </div>
    </fieldset>
    </div>
    </form>
    
    <!-- Solar's Popup form! -->
    <form id="popForm" action="javascript:unPop();">
    <div id="popup">
    <h2 id="popHead"></h2>
    <div id="popBod">
    <p id="popText"></p>
    <fieldset id="popCtrls"></fieldset>
    </div><!-- popBod -->
    </div><!-- popup -->
    </form><!-- popForm -->
    <!-- End of Solar's Popup form -->
    
    </body>
    </html>

  8. #8
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: $_POST empty in PHP

    Your form is faulty. You made two classes of mistake. In some places you use id='something' to label your input widgets. In fact you should use name='something'. id and name are not the same thing. In others you don't provide a name=. Change the textarea from id='articleContent' to name='articleContent' and you will see something come through.

  9. #9
    Join Date
    Aug 2008
    Location
    East England
    Posts
    50

    Default Re: $_POST empty in PHP

    THANK YOU!

    I got so used to never using name= in xhtml that I forgot it was an integral component of forms!

  10. #10
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: $_POST empty in PHP

    Presumably you need both id= and name= when the input widget is also referred to from JS using getelementbyid.

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

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