TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-09-2008, 09:26 AM   #1 (permalink)
The Contributor
 
pipesportugal's Avatar
 
Join Date: May 2008
Location: Oporto-Portugal
Posts: 32
Thanks: 11
pipesportugal is on a distinguished road
Default HttpRequest::getPostFields

Hello dear colleagues from the talkphp forum,

I have been looking for an example of how to use the above function - HttpRequest::getPostFields.

I am trying to retrieve at my "update_any_table.php" script the name of the received posted variables, so that I can use it as "action" program of all my "update" forms.

Can someone help ?

Thanks in advance,
pipesportugal is offline  
Reply With Quote
Old 09-09-2008, 09:12 PM   #2 (permalink)
The Contributor
 
pipesportugal's Avatar
 
Join Date: May 2008
Location: Oporto-Portugal
Posts: 32
Thanks: 11
pipesportugal is on a distinguished road
Default

I don't drink alcohol but for someone who reads my previous post, surely will not think that way.
Sorry folks!

I want to retrieve the posted variable names in order to be able to perform an update at my mySQL database.

If I can't do it that way, I can always (also) post the variable names from the previous form and retrieve them together with the variables values.

Hope it's more clear now,
Regards,
pipesportugal is offline  
Reply With Quote
Old 09-17-2008, 10:57 PM   #3 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 312
Thanks: 8
tony is on a distinguished road
Default

I am not a professional, but I think this might work:

PHP Code:
if($_POST){
    
$vars=$_POST;
    
$names=array();
    foreach(
$vars as $key => $value){ //this would loop for every element in the array
        //$key would have the name of the element
        //$value has the value of the element
        
$names[]=$key
    
}

hope that helps
tony is offline  
Reply With Quote
The Following User Says Thank You to tony For This Useful Post:
pipesportugal (11-18-2008)
Old 09-18-2008, 12:01 AM   #4 (permalink)
The Addict
 
Enfernikus's Avatar
 
Join Date: Jun 2008
Posts: 335
Thanks: 2
Enfernikus is on a distinguished road
Default

PHP Code:

$pstArrKeys 
array_keys($_POST); 
Enfernikus is offline  
Reply With Quote
Old 11-18-2008, 10:26 PM   #5 (permalink)
The Contributor
 
pipesportugal's Avatar
 
Join Date: May 2008
Location: Oporto-Portugal
Posts: 32
Thanks: 11
pipesportugal is on a distinguished road
Default

Hello there !

Thank You both for the replies.

I tried Enfeernikus suggestion at first, and it gave me an error, so I abandoned it, maybe it's due to an older php version of my lodging supplier, I imagine, I don't know really.

Tony's suggestion functioned right out of the box.

Regards,
pipesportugal
pipesportugal is offline  
Reply With Quote
Old 11-19-2008, 01:10 AM   #6 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,267
Thanks: 90
Wildhoney is on a distinguished road
Default

Could you show us the error for Enfernikus's suggestion of array_keys, please? I am curious, as that function is available in both PHP4 and PHP5.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:31 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design