Re: How to retrieve form data?

From: Date: Mon, 28 Feb 2005 03:10:50 +0000
Subject: Re: How to retrieve form data?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-209569@lists.php.net to get a copy of this message
Gregg Nelson wrote:
The first execution of the file below produces the expected output: Request Method: GET Clicking on the Submit button outputs: Request Method: POST $_POST array contains: Array Why don't I see one of the values from the select item? ---------------------------------------------------------------------------- --------------- <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>
Your foreach loop isn't going to print what _you're_ expecting. foreach ( $_POST as $key => $value ) { echo ( $value . "<br />" ); } but print_r() would be much easier... echo ( "<pre>" ); print_r ( $_POST ); echo ( "</pre>" ); -- By-Tor.com ...it's all about the Rush http://www.by-tor.com

« previous php.general (#209569) next »