简体   繁体   中英

How to add a function to a form

I have a form like this :

$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;

I want to add a function to this form, so when "Buy" is clicked, then in MySQL a database is created for this user with the information of the selected item and his account id with a pending transaction status, and then the form redirects him to the webpage included.

I can manage the MySQL part, but the form only redirects the user to the given webpage, and i can not add users information to the database.

Is there a way I can add a database row for this user, then redirect him to the payment webpage ? ( except creating another page )

<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>

Then on the target page put:

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

To access the 'customer-name' variable for example just do:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM