PHP return value retrieval-php Tutorial

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.