The data submitted by php is generated as a txt file. _ PHP Tutorial

Source: Internet
Author: User
Tags learn php programming
The data submitted by php is generated as a txt file ,. The data submitted by php is generated as a txt file. There are two files in total. the specific link to the database is directly removed. the front-end is the submitted text part, one row at a time, after the submission, the data submitted by another php file is generated as a txt file,

There are two files in total. the specific link to the database is directly removed. the front-end is the submitted text part, one line, and the other program file is processed after the submission, then generate the corresponding txt file according to the submitted file name and add data to the txt file. before using the file, create a test file in the root directory.

The front-end form file is as follows (saved as dcwz. php ):

<? Phperror_reporting (0); // require_once (".. /config. php "); // require_once (".. /admin/ly_check.php "); // $ SQL =" select * from leibie "; // $ rs = mysql_query ($ SQL);?>
 Untitled Document
 
  

The processing program for generating txt files is as follows (saved as dcwj_cl.php ):

<? Php $ biaoti_cl = explode ("\ n", $ biaoti); $ biaoti_num = count ($ biaoti_cl); $ file_type = "txt"; for ($ I = 0; $ I <$ biaoti_num; $ I ++) {$ file_name = mb_convert_encoding ($ biaoti_cl [$ I], 'gbk', "UTF-8 "); $ data [] = array ("tom", "boy", 20); $ dir = dirname (_ FILE __). "\ text \"; $ string = ""; foreach ($ data as $ k => $ v) {foreach ($ v as $ vstr) {$ string. = mb_convert_encoding ($ vstr, 'gbk', "UTF-8") ;}}$ string. = "\ r \ n"; $ filedir = $ dir. trim ($ file_name ). ". ". $ file_type; $ fileurl = str_replace ('','', $ filedir); $ fp = fopen ($ fileurl, "a +"); echo 'create '. $ fileurl.'
'; Fwrite ($ fp, $ string); fclose ($ fp) ;}?>

The above is all the content of this article. I hope it will help you learn php programming.

Commit. There are two files in total. the specific link to the database is directly removed. the foreground is the submitted text part, one line, and the other after the submission...

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.