如何向表单添加函数

时间:2012-05-16 14:16:51

标签: php

我有一个这样的表格:

$form  = '<form action="https://www.zarinpal.com/users/pay_invoice/'.$res.'"
method="post" target="_parent" ><input type="submit"  value="Buy"/></form>';
$form .= '</form>';
echo $form;

我想在此表单中添加一个函数,因此当点击“Buy”时,在MySQL中会为该用户创建一个数据库,其中包含所选项目的信息和他的帐户ID以及待处理的事务状态,然后表单将他重定向到包含的网页。

我可以管理MySQL部分,但表单只将用户重定向到给定的网页,我无法将用户信息添加到数据库。

有没有办法为这个用户添加数据库行,然后将他重定向到付款网页? (除了创建另一页)

1 个答案:

答案 0 :(得分:0)

<form action="https://www.zarinpal.com/users/pay_invoice/<?=$res ?> method="post" target="_parent" >
    <input type="test" name="customer-name" />
    <input type="submit"  value="Buy"/>
</form>

然后在目标页面上放置:

<?
print_r($_POST);
## That will let you know what is being posted from the form
?>

要访问'customer-name'变量,例如只需执行:

$customerName = $_POST["customer-name"];