【问题标题】:How do I setup where my data goes for my form? HTML如何设置我的数据用于我的表单的位置? HTML
【发布时间】:2013-11-28 04:08:32
【问题描述】:
我为我的网站制作了一个表格,我只是不知道如何设置他们填写的信息的去向。我在论坛上搜索了信息,据我所知,我需要在某个地方创建一个 PHP 页面。谁能给我一些关于如何开始的提示?
这是我的代码上提交按钮的代码
<form name="input" action="html_form_action.asp" method="get">
<input type="submit" value="Submit" formaction="Form/New Text Document.txt"/>
</form>
【问题讨论】:
标签:
php
html
forms
location
【解决方案1】:
您的数据将转到 html_form_action.asp,使用一些变量收集那里的数据以供进一步使用。要使用 PHP ,请将操作更改为 "Some_PHP_PAGE_NAME.php"
<form action="Some_PHP_PAGE_NAME.php" method="get">
NAME :<input type="text" name="fname">
PHP 代码
<?php
$name =$_GET_['fname'];
echo $fname;
?>
【解决方案2】:
看下面的例子
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html>
当用户填写上面的表单并点击提交按钮时,表单数据被发送到一个名为“welcome.php”的 PHP 文件中进行处理。表单数据使用 HTTP POST 方法发送。要显示提交的数据,您可以简单地回显所有变量。 “welcome.php”看起来像这样:
<html>
<body>
Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html>
【解决方案3】:
action 属性指定提交表单时将表单数据发送到何处。在您的情况下,表单数据发送到action="html_form_action.asp"
提交时,将表单数据发送到名为“html_form_action.asp”的文件(以处理输入)。
你甚至可以在同一页面上发送值。
<form name="input" action="html_form_action.asp" method="get">
Firstname: <input type="text" name="fname" value="">
<input type="submit" value="Submit" />
</form>
【解决方案4】:
formaction 属性覆盖<form> 元素的action 属性。
所以从提交中删除 formaction="Form/New Text Document.txt"