/    Sign up×
Community /Pin to ProfileBookmark

loop thru post variables

Hi all. I finally am getting tired of working with these 60 field forms and having to write the mysql and php scripts, so i want to write a class to do all this for me, i will post this up here once i get it done, but I have one question. In ASP you can cycle thru all post variable and get their value plus their name. What is the best way of doing this in PHP? I want to create a loop something like this

loop thru all POST or GET variables
place variable NAME into $array[$i][0]
place variable VALUE into $array[$i][1]

Thanks for any help.

PS. I did look around on google and was unable to find something like this.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@chazzyJan 27.2006 — you could do:
[code=php]
foreach($_POST as $key=>$value){
//do stuff
}
[/code]


However, I have to say, it will be a very insecure form doing it that way.

Why do you have 60 form fields? Doesn't seem like a great design in my opinion.
Copy linkTweet thisAlerts:
@cafrowauthorJan 27.2006 — some of our clients send us PDF files that they want turned into HTML and saved to a mysql database. Like insurance applications and such. As for security i will be making sure i take every step to make it secure.

Thanks for the example, i tried it and it works great.
Copy linkTweet thisAlerts:
@chazzyJan 27.2006 — Hmm.

So every form's a new row? so no chance of a repeat customer?
Copy linkTweet thisAlerts:
@NogDogJan 28.2006 — You might also want to look at [url=http://www.php.net/extract]extract()[/url].
Copy linkTweet thisAlerts:
@cafrowauthorJan 29.2006 — Hmm.

So every form's a new row? so no chance of a repeat customer?[/QUOTE]


No not that at all. What i am doing is calling the HTML Form fields the same name as the column names in mysql, this way i do not have to write the insert statement. i am almost done with the class, i will post it here in a few mins.
×

Success!

Help @cafrow spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...