-2

我遇到了一个小问题,希望有人可以帮助我。

我做了一个表格,它工作正常:

http://www.volunteeringnews.com/formorg.php

如果我点击发送,它会返回一条消息,说明用户已创建。

这样可以,但是如果我访问http://www.volunteeringnews.com/并在“组织”下单击“提交”,它不起作用。提交按钮只是一个指向 formorg.php 的链接。

我尝试将其添加到 index.php 但没有成功。

$action = isset($_POST['action']) ? $_POST['action'] : "";

//include database connection
include 'mysqli.php';

有人可以看看吗?

谢谢!

4

2 回答 2

2

$_POST 变量将填充传递给它的表单数据。

所以在你的表格上你会有这样的东西:

<form action="http://www.volunteeringnews.com/formorg.php" method="post">
<input type='text' id='firstname' name='firstname'>
<input type='submit'>

然后,当您提交该表单时,formorg.php 将使用您为表单字段提供的名称填充 $_POST 数组。因此,例如,要访问用户为 firstname 字段填写的任何值,您将访问 $_POST['firstname']

于 2013-09-09T15:21:07.540 回答
0

我能看到的第一件事是 Action 不正确。

Normaly 您应该将 Action 设置为您希望 Post 数据为的脚本:

<form action="http://www.volunteeringnews.com/formorg.php" method="post" border="0">

否则,如果您没有获得请求值,您将把 Post 定向到 index.php。

于 2013-09-09T14:59:29.340 回答