PHP return value retrieval & lt; form & nbsp; actioncomment01.php & nbsp; methodpost & gt; & lt; p & nbsp; aligncenter & gt; & lt; textarea & nbsp; nametxt & nbsp; rows10 & nbsp; cols40 & gt; & lt; textarea & gt; PHP return value acquisition problem
$ Yjj = key ($ _ GET );
$ Logi = file ("./data/list.txt", FILE_IGNORE_NEW_LINES );
Foreach ($ Logi as $ Key => $ Val ){
List ($ num, $ title) = explode ("|", $ Val );
If ($ title = $ yjj)
{
$ Comment = $ _ POST ['txt '];
$ Filename = "Item" .({num}.'.txt ';
$ File = fopen ('./data/comments/'. $ filename, 'A ');
Fwrite ($ file, $ Comment );
Fclose ($ file );
}
}
?>
$ Yjj = key ($ _ GET) is the value returned from the previous page. I want to set a text box on this page, obtain the input content as $ Comment = $ _ POST ['txt ']. However, if the input content fails to be obtained multiple times, the value cannot be obtained. please advise
PHP
------ Solution --------------------
The pasted code is the content of comment01.php, right?
If yes, there is a conflict.
1. $ yjj = key ($ _ GET); is used to obtain the parameters submitted by the get method in another post.
The code here does not produce get parameters.
Therefore, $ yjj = key ($ _ GET); the value is only available when the first entry is made.
Your operations are performed when if ($ title = $ yjj) is set up, so it is impossible to perform operations as long as it is not the first entry.
2. when you enter the file for the first time, $ Comment = $ _ POST ['txt ']; is empty because the get method is used. although the file is written, the value is null.
After the form is filled in and submitted, it enters the 1 state and does not execute the Write file.