Php submitted data is generated as a txt file _ php skills

Source: Internet
Author: User
Tags learn php programming
This article mainly introduces the data submitted by php to generate the txt file, which is of reference value. if you need it, you can refer to a total of two files, the specific link to the database is directly removed. the front-end is the submitted text part, one line, after the submission, another program file is processed, and then the corresponding txt file is generated according to the submitted file name, and add data to the txt file. before using the file, you must create a new 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.

Related Article

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.