RE: [PHP] Can't read $_POST array

From: Date: Wed, 18 Aug 2010 22:11:28 +0000
Subject: RE: [PHP] Can't read $_POST array
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-307553@lists.php.net to get a copy of this message
You've got something jacked. DO NOT proceed with your coding using this hack. Put this in a blank file named whatever_you_want.php and hit it with your web browser. --------------------------------------------------------------------------- ----- <?php if ($_POST['action'] == 'Go') print_r($_POST); ?> <form action="<?=$_SERVER['SCRIPT_NAME']?>" method="POST"> <select name="my_select"> <option value="foo">foo</option> <option value="bar">bar</option> </select> <input type="submit" value="Go" name="action" class="button submit"/> </form> --------------------------------------------------------------------------- ----- > -----Original Message----- > From: Brian Dunning [mailto:brian@briandunning.com] > Sent: Wednesday, August 18, 2010 2:23 PM > To: PHP-General > Subject: Re: [PHP] Can't read $_POST array > > This was the complete code of the page (this is the POST > version not the REQUEST version): > > <?php > $response = print_r($_POST, true); > echo $response; > ?> > > Returns an empty array no matter what POST vars are sent. We > fixed it by changing it to this, which I've never even heard > of, but so far is working perfectly: > > <?php > $response = file_get_contents('php://input'); > echo $response; > ?> > > I have no idea what the problem was. Thanks to everyone for your help. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

<?php if ($_POST['action'] == 'Go') print_r($_POST); ?> <form action="<?=$_SERVER['SCRIPT_NAME']?>" method="POST"> <select name="my_select"> <option value="foo">foo</option> <option value="bar">bar</option> </select> <input type="submit" value="Go" name="action" class="button submit"/> </form>
« previous php.general (#307553) next »