GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Mar-2004, 11:23
Dunc Dunc is offline
New Member
 
Join Date: Nov 2003
Location: West Mids, UK
Posts: 5
Dunc is on a distinguished road

getting variables from $_GET & $_POST


Is there any easy way of extracting GET and POST variables? I'm writing a guest book that will use both get and post methods and wondered what the best method to use is to get these variables.
So far I have used the following code:

Quote:
$pvars = print_r(array_keys($_POST),true);
echo ($pvars);
which gives me all the array keys:
Array ( [0] => name [1] => email [2] => homepage [3] => url [4] => comments )

The only way I can think of is to EXPLODE this, then pick out any array elements like [0] and => so I'm just left with the array keys, then go through these and get the values, which seems very long winded.
I have looked through the PHP website and cant find anything that might be useful, so help would be greatly appreciated

Thanks in advance

Dunc
  #2  
Old 29-Mar-2004, 06:37
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
If your script accepts both (i.e. $_GET and $_POST) you can retrieve the super global array $_REQUEST instead.

Then, about getting these 'extracted', you can read up on the PHP function extract() and see if that does what you want it to do.

PHP Code:

// extracting the user input either via GET or POST
extract( $_REQUEST ); 


  #3  
Old 29-Mar-2004, 06:45
Dunc Dunc is offline
New Member
 
Join Date: Nov 2003
Location: West Mids, UK
Posts: 5
Dunc is on a distinguished road
Thumbs up

Thanks for that. It sounds just what I'm looking for. I found the following:
Quote:
foreach($_POST as $name=>$value)
{
echo $name." - ".$value."<br /> ";
}

But as you can see this has to be done for $_GET and $_POST and my script will use both of these.
I will have a tinker with your example when I get back from work.

Many thanks
Dunc
:-)
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
passing variables out of an iframe by url JUNK KED MySQL / PHP Forum 5 31-Jul-2007 10:33
Not finding POST variables shrdlu Apache Web Server Forum 2 22-Jan-2004 19:50
Apache on Windows XP and passing variables Jos Elkink Apache Web Server Forum 4 21-Nov-2003 03:21
Mail message with variables ukrspp21 MySQL / PHP Forum 2 05-Aug-2003 06:10
PHP variables nniehoff MySQL / PHP Forum 7 26-Jul-2002 07:25

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 09:22.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.