If I use the standard PayPal form for payments can I also update my db at the same time, by changing the code slightly to include the update details?
This is the standard PayPal payment form I want to use – Will change as necessary..
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="payPalForm">
<input type="hidden" name="item_number" value="01 - General Payment to FreelanceSwitch.com">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="business" value="your@paypalaccount.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="return" value="http://freelanceswitch.com/payment-complete/">
Item Details:<br /><input name="item_name" type="text" id="item_name" size="45">
<br /><br />
Amount: <br /><input name="amount" type="text" id="amount" size="45">
<br /><br />
<input type="submit" name="Submit" value="Submit">
</form>
This is my update coding in my page:
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form")) {
$updateSQL = sprintf("UPDATE db SET payment_page_completed=%s WHERE id=%s",
GetSQLValueString($_POST['payment_page_completed'], "text"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_connAdmin, $connAdmin);
$Result1 = mysql_query($updateSQL, $connAdmin) or die(mysql_error());
//$updateGoTo = "confirmation"; WILL NEED TO CHANGE AS NEEDS TO GO TO PAYPAL
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
This is my current form
<form action="<?php echo $editFormAction; ?>" name="form" class="" id="form" method="POST" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $_SESSION['id']; ?>" readonly="readonly">
<input type="hidden" name="payment_page_completed" value="yes" readonly="readonly">
</form>
Thank you
Yes you can do it in two ways by submitting form to two sides with two submits on one form, one to paypal and other to the page where you can save it in your db.
EDIT 1:
In your form add two submits like this:
and in your script add this:
EDIT 2:
using single submit for two form actions
add this in your form:
and in script add this:
It works for me. 🙂
EDIT 3:
savedata.php may include code like;
Hope this helps.