Difference between revisions of "Receiving GET parameters"
From MyWiki
| (4 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | + | <source lang="php"> | |
| − | <source lang=" | + | <html> |
| − | + | <head> | |
| − | + | <title>PHP Get Results</title> | |
| − | + | </head> | |
| − | + | ||
| − | + | ||
| − | <html> <head><title>PHP Get Results</title></head> | + | |
<body> <?php | <body> <?php | ||
// Show all URL parameters (and // all form data submitted via the | // Show all URL parameters (and // all form data submitted via the | ||
| Line 13: | Line 10: | ||
{ echo $key, ' => ', $value, "<br/>n"; } | { echo $key, ' => ', $value, "<br/>n"; } | ||
// Show a particular value. | // Show a particular value. | ||
| − | $id = $_GET['id']; if($id) | + | $id = $_GET['id']; |
| + | if($id) | ||
{ echo '<p/>ID: ', $id, "<br/>n"; } | { echo '<p/>ID: ', $id, "<br/>n"; } | ||
else { echo '<p>No ID parameter.</p>'; } | else { echo '<p>No ID parameter.</p>'; } | ||
?> | ?> | ||
| − | </body> </html> | + | </body> |
| + | </html> | ||
</SOURCE> | </SOURCE> | ||
Latest revision as of 21:33, 14 September 2014
<html> <head> <title>PHP Get Results</title> </head> <body> <?php // Show all URL parameters (and // all form data submitted via the // 'get' method) foreach($_GET as $key=>$value) { echo $key, ' => ', $value, "<br/>n"; } // Show a particular value. $id = $_GET['id']; if($id) { echo '<p/>ID: ', $id, "<br/>n"; } else { echo '<p>No ID parameter.</p>'; } ?> </body> </html>