Re: How to retrieve form data?

From: Date: Mon, 28 Feb 2005 04:44:40 +0000
Subject: Re: How to retrieve form data?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-209573@lists.php.net to get a copy of this message
Gregg Nelson wrote: <snip>
Clicking on the submit button now produces: ---------------------------------------------------------------------- Request Method: POST Using foreach loop, $_POST array contains: Array Using printr, $_POST array contains: Array (
    [item] => Array
        (
            [0] => select item 1
        )
) -------------------------------------------------So what exactly does this mean?: $Post is an array thatconsists of one item that is also an array, that being the "item" array consisting of one entry containing the select string?If so, can I access the "item" array itself? I tried this in the script but nothing was echoed:echo $item[0]
No, that's not how it should be coming across. Not unless you modified your original form to send item as an array (like you would do if it was a multi-select). If your HTML form hasn't changed from how you have it below, and 'item' is still coming across as an array, you have a problem sowhere else. <original form?>
--------------- <html> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" > <select name="item" >
    <option value="select item 1" > item 1 </option>
    <option value="select item 2" > item 2 </option>
</select> <input type=submit value="Submit"> </form> <?php echo "Request Method: ".$_SERVER['REQUEST_METHOD']."<br />"; if ($_SERVER['REQUEST_METHOD'] == "POST"): echo '$_POST array contains:'."<br />"; foreach ($_POST as $value) {echo $value."<br />";} endif; ?></html>
-- By-Tor.com ...it's all about the Rush http://www.by-tor.com

« previous php.general (#209573) next »