/    Sign up×
Community /Pin to ProfileBookmark

variable creation using $_POST

i have a mailer script which i want to modify the way i retrieve variables from the post. i would like it to create a variable for each input and assign the variable the value of that post i tried a little test but it failed

[code=php]
<?php
if ($_SERVER[‘REQUEST_METHOD’] == “POST”) {
foreach ($_POST as $key => $value) {
return “‘$’$key ‘=’ $value”;
}
echo $quantity
?>[/code]

the echo was just to test and see if i could create the variable the way i wanted to

the return line looks like something from a Frankenstein flick lol. if anyone has any suggestions i would appreciate them

thanks
-nick

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@jasonahouleNov 20.2007 — [code=php]
<?php
foreach($_POST as $key => $value) {
${$key} = $value;
echo ${$key} . '<br/>';
}
?>
[/code]
Copy linkTweet thisAlerts:
@TecBratNov 23.2007 — I am only posting here to make it show up when I search for my own posts. I might have 2cents to throw in later.
×

Success!

Help @iiz 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 5.28,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...