PHP, convert value of variable into string.
Hallo,
I can not manage some task
Code:
$field_name = "surname";
/* then I need to put this value to the $_POST array
something like this */
$var = $_POST[$field_name] ;
/* I tried like this but it doesn't work
$var = $_POST['\''.$field_name.'\'']);
could anybody write me how I can manage when the 'field_name' value is changed dynamicly
Thanks in advance
Re: PHP, convert value of variable into string.
$_GET and $_POST are read only set by the data returned in a form or through AJAX.
Re: PHP, convert value of variable into string.
so it means that there is no way to do it,
Am I right ?
Re: PHP, convert value of variable into string.
Not what you are describing. What exactly are you wanting to do?
Re: PHP, convert value of variable into string.
I hve solved it but in a other way, it means that I put in my Form the field with the fixed name. But I still thin if it is possible
what I wanted to do:
my php code creates a FORM where the field_name depends on some condition let say that on Monday the filed name must be 'Mo' and on the Tusday the filed name must be 'Tu' and so on ..., it is just a stupid example but I I theoreticaly wonder how it could be implemented in php code.
If you could suggest me some way it would be nice.
Re: PHP, convert value of variable into string.
I'm sorry, but you're still not explaining yourself clearly. Why does it have to come from the form content?
Re: PHP, convert value of variable into string.
Quote:
Originally Posted by Andrzej
what I wanted to do:
my php code creates a FORM where the field_name depends on some condition let say that on Monday the filed name must be 'Mo' and on the Tusday the filed name must be 'Tu' and so on ..., it is just a stupid example but I I theoreticaly wonder how it could be implemented in php code.
If you could suggest me some way it would be nice.
In that case you would access $_POST[$field_name], as per your first post. The value of $field_name would be exactly the same as that used to create the form.
Re: PHP, convert value of variable into string.
sorry, maybe my english is not good enough
for instance:
PHP Code:
$field_name = GetFieldName();
$HTML .= '<form method="post" name=".myform" action="'.$this->ScriptFileName.'">';
//...
$HTM> .= "<input type=text name=" . $field_name . " value=" . $val . "</td>"
// then I need to get value typed by a user
$test = $_POST=['$filed_name']; // <= ofcourse it is wrong, but how it should be ...
Re: PHP, convert value of variable into string.
Get rid of the single quotes from the $_POST variable.
Re: PHP, convert value of variable into string.
Thank you
it works, thank you that you was patient with me.