Jump to content

$_POST identifier


suohryu

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/153159-_post-identifier/
Share on other sites

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 />";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/153159-_post-identifier/#findComment-804519
Share on other sites

<?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

Link to comment
https://forums.phpfreaks.com/topic/153159-_post-identifier/#findComment-804628
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.