Php 将数据收集到表中
我有一个文件“collecting data.html”,其中包含以下代码:Php 将数据收集到表中,php,html,collections,Php,Html,Collections,我有一个文件“collecting data.html”,其中包含以下代码: <html> <body> <form action="collect.php" method="get"> name : <input type="text" name="name"> email : <input type="text" name="email"> telephone: <input type=
<html>
<body>
<form action="collect.php" method="get">
name : <input type="text" name="name">
email : <input type="text" name="email">
telephone: <input type="text" name="telephone">
<input type="submit" value="save">
</form>
</body>
</html>
姓名:
电邮:
电话:
i何时创建“collect.php”文件以收集所有数据(名称电子邮件电话)
然后保存在表中的另一个文件“save.html”中
如果有人知道怎么做,这将对我有很大帮助。非常快速和肮脏的回答,记得清理你的输入
<?php
//collect.php
$html = "<html><head><title>Test</title></head><body><table>";
foreach($_REQUEST as $k=>$v) {
$html .= "<tr><td>$k</td><td>$v</td></tr>";
}
$html .= "</table></body></html>";
file_put_contents('save.html',$html);
?>
由于您可以使用此选项进行学习,请先从基本方法开始,然后再选择更高级的选项 首先,你的表单需要是一个帖子,而不是一个GET
<form action="collect.php" method="POST">
这将把值发布到collect.php
在collect.php上,需要收集值
<?php
if(isset($_POST['name']) {
// Do Something
;}
if(isset($_POST['email']) {
// Do Something
;}
if(isset($_POST['telephone']) {
// Do Something
;}
?>
你试过php吗?我懂html,但php就是这样hard@Peter最好从basic开始学习PHP。是的,我会的,但我今天需要找到解决方案,如果你知道解决方案“我今天需要找到解决方案”,那么请帮助我。看一下如何从表单中获取值,或者循环它们,或者保存到文件(查看文件权限)。好lucki需要将数据保存到表中。这是我的问题