I made a form. Currently, this form performs the following operations:
- the customer fills out a form (creates an order)
- clicks the submit button
- records of all forms are written to the database.
I would like to change it to perform the following operations:
- customer fills out a form
- At the end of the form there is a text box indicating that this order will cost him.
- clicks the submit button (if accepts the price)
- redirected to paypal
- if the payment is successful → all entries in the form are entered into the database. Error Else -> echo ".
Here is what I have done so far:
"form.php" content
<html><head><title>Title</title></head><body>
<form action="php-form-processor.php" method="post">
<table border="0" cellspacing="5" width = "500">
<tr>
<td align="right" width="160">Choose an Item:</td>
<td align="left">
<select name="formItem" value="<?=$varItem;?>" class="input_full" >
<option value="1">Cheese</option>
</select>
</td>
</tr>
<tr bgcolor="#D0E8F5">
<td align="right" >Item count:</td>
<td align="left">
<input type="text" name="formItemCount" maxlength="50" value="<?=$varItemCount = 1;?>" class="input_full" />
</td>
</tr>
</table>
<p align="center">
<input type="submit" name="formSubmit" align = "center" value="Submit" />
</p>
</form></body></html>
"php-form-processor.php" content
<?php
if($_POST['formSubmit'] == "Submit")
{
$varItem = $_POST['formItem'];
$varItemCount = $_POST['formItemCount'];
//database stuff
$username = "...";
$password = "...";
$hostname = "...";
// connect and add to the database varItem and varItemCount
mysql_query($sql);
mysql_close($dbhandle);
}
?>
, stackoverflow. "varItem" "varItemCount". "Pay with PayPal" .
paypal Sandbox "" "".
?
: , , . :
:
- - + ID + 1 "", : 1 - 0 -
- ( ": URL" ) Form_Processing Paypal_Form
- "", POST
- PaypalForm "" carier .
- : → "" 1 (). "custom", i.e.:
$sql = "UPDATE paypal_test SET payed = '1' WHERE id = '". $_ POST [' custom ']. "'";
. , , "" . "", : if (current_date.days - old_date.days > 7) → . !