Simple PHP program-related question 2

Source: Internet
Author: User
Simple PHP program Problem 2 is not a problem, and it is simple to ask, there will be many small series of problems in the future. & Lt ;? Phpfunctionsubmit1 ($ title, $ belong, $ comment) {$ fp = fopen (& quot; news1.php & quot;, & quot; simple PHP program Question 2
The younger brother asked me a few simple questions. there will be many small series of questions in the future.
Function submit1 ($ title, $ belong, $ comment ){
$ Fp = fopen ("news1.php", "rw ");
Fwrite ($ fp, $ getphp ($ name, $ commment ));
}
?>




Control






This program generates a text area in the following HTML program. a php file is generated through the submit button, put the content in the text area into the php file (including the title and content of the article ).
Ques1: But after I click submit, the generated PHP file is not found.
Ques2: How do I write the content filled in the lifecycle area to the PHP file and generate a page. I like to make the title of my article become the file name of my php file.
Ques3

------ Solution --------------------
Q3: ewebeditor
------ Solution --------------------
Ji
------ Solution --------------------
$ Getphp ($ name, $ commment)
Onclick = "submit1 ($ title, $ belong, $ comment );"
What do you want to do ???
------ Solution --------------------
It is best not to use this method. this method of "stealing" is not supported by PHP.

Use $ _ POST or $ _ GET

Onclick = "submit1 ($ title, $ belong, $ comment);" all come out. you think it's JavaScript.


If ($ _ GET ){
File_put_contents ('news1. php', $ _ GET ['title'], $ _ GET ['belong '], $ _ GET ['comment']);
}
?>
------ Solution --------------------
The most direct reason is that you use the client event (onclick) to call the server-side function (submit1 ($ title, $ belong, $ comment )).
This is impossble mission!

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.