suohryu Posted April 8, 2009 Share Posted April 8, 2009 Hi all long time since i been here hope everyone is keeping cool so it has come to me lately that i should be able to do this but cant figure out how what i am trying to do is use the $_Post array in a way so i can auto generate forms on the flybut i need to be able to do one thing i cant figure out which is how to do 1 echo the variable identifier that's it and what i mean is say i had a input called "name" now what i want to be able to do is something like this echo "my". <Missing bit> ." is ". $_POST['name']; which in the public say something like my name is bob now this is probably a very simple thing to do and if anyone knows i would be very grateful Quote Link to comment https://forums.phpfreaks.com/topic/153159-_post-identifier/ Share on other sites More sharing options...
premiso Posted April 8, 2009 Share Posted April 8, 2009 http://www.tizag.com/phpT/forms.php This is basic HTML with PHP. See the above tutorial for more information about it. Quote Link to comment https://forums.phpfreaks.com/topic/153159-_post-identifier/#findComment-804518 Share on other sites More sharing options...
thebadbad Posted April 8, 2009 Share Posted April 8, 2009 Are you looking for something like this?: <?php $str = 'name'; echo "my $str is " . $_POST[$str]; ?> Or you could loop through the post array like this, getting access to both keys and values: <?php foreach ($_POST as $key => $value) { echo "The value associated with the key '$key' is '$value'.<br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/153159-_post-identifier/#findComment-804519 Share on other sites More sharing options...
suohryu Posted April 8, 2009 Author Share Posted April 8, 2009 <?php foreach ($_POST as $key => $value) { echo "The value associated with the key '$key' is '$value'.<br />"; } ?> thank you this is exactly what i was after so thank you are you able to explain this code at all tho in terms of how it works $_POST as $key => $value Quote Link to comment https://forums.phpfreaks.com/topic/153159-_post-identifier/#findComment-804628 Share on other sites More sharing options...
thebadbad Posted April 8, 2009 Share Posted April 8, 2009 You're welcome. That's just one of the two syntaxes of a foreach loop. Could be translated to: Loop through each element of the array $_POST, and assign the key to $key and the value to $value on each iteration. Quote Link to comment https://forums.phpfreaks.com/topic/153159-_post-identifier/#findComment-804695 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.