faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

56 of 67 people (84%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

PHP: Operation:Get:Form: Variable: All: How to get all your form variables? [$_POST/$_GET/$_REQUEST]

Mar 20th, 2008 17:17
ha mo, Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 09 March 2005 - 08:21 pm ----------------------

PHP: Operation:Get:Form: Variable: All: How to get all your form 
variables? [$_POST/$_GET/$_REQUEST]

---

Use the associative arrays

$_POST
for your action="post" data on your HTML <FORM>

$_GET
for your action="get" data HTML <FORM>

$_REQUEST
for your action="post" or action="get" data HTML <FORM>

---
---

Steps: Overview:

 1. -Create a .php file

--- cut here: begin --------------------------------------------------

<?php
// ------------------------------------
print '$_POST array';
// ------------------------------------
print "<BR/>";
// ------------------------------------
foreach ( $_POST as $key => $value ) {
 print $key . " " . "=" . " " . $value;
 print "<BR/>";
}
// ------------------------------------
print "<BR/>";
// ------------------------------------
print "<BR/>";
// ------------------------------------
print '$_GET array';
// ------------------------------------
print "<BR/>";
// ------------------------------------
foreach ( $_GET as $key => $value ) {
 print $key . " " . "=" . " " . $value;
 print "<BR/>";
}
// ------------------------------------
print "<BR/>";
// ------------------------------------
print "<BR/>";
// ------------------------------------
print '$_REQUEST array';
// ------------------------------------
print "<BR/>";
// ------------------------------------
foreach ( $_REQUEST as $key => $value ) {
 print $key . " " . "=" . " " . $value;
 print "<BR/>";
}
// ------------------------------------
?>

--- cut here: end ----------------------------------------------------

 2. -Upload this file to your PHP server

     1. e.g. upload this as

      yourtest.php

 3. -Open your webbrowser

 4. -Type the URL location of this php file

     1. e.g. type

       http://www.yourwebsite.com/yourtest.php?test1=1&test2=2&test3=3

 5. -This will show as a response

--- cut here: begin --------------------------------------------------

$_POST array


$_GET array
test1 = 1
test2 = 2
test3 = 3


$_REQUEST array
test1 = 1
test2 = 2
test3 = 3

--- cut here: end ----------------------------------------------------


---
---

Internet: see also:

---



----------------------------------------------------------------------



http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.yamot.com
http://www.mozmar.com
http://www.templatestemp.com