|
-
September 21st, 2010, 07:06 AM
#1
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
-
September 21st, 2010, 12:52 PM
#2
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.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
September 23rd, 2010, 11:57 AM
#3
Re: PHP, convert value of variable into string.
so it means that there is no way to do it,
Am I right ?
-
September 23rd, 2010, 01:28 PM
#4
Re: PHP, convert value of variable into string.
Not what you are describing. What exactly are you wanting to do?
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
September 23rd, 2010, 01:44 PM
#5
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.
-
September 23rd, 2010, 02:47 PM
#6
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?
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
September 23rd, 2010, 03:21 PM
#7
Re: PHP, convert value of variable into string.
 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.
-
September 23rd, 2010, 03:26 PM
#8
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 ...
-
September 23rd, 2010, 05:15 PM
#9
Re: PHP, convert value of variable into string.
Get rid of the single quotes from the $_POST variable.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
September 24th, 2010, 02:13 AM
#10
Re: PHP, convert value of variable into string.
Thank you
it works, thank you that you was patient with me.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|