我希望能夠提交表單,使用Javascript處理它,然後PHP +進行API調用,然後呈現感謝消息或顯示錯誤數組與API。尋找處理和隱藏HTML表單的提示
到目前爲止,我已經能夠成功地打電話了,謝謝,但之後一直無法隱藏表格。
http://www.wilsonkeenan.com/learningphp/DoDirectPayment.php
什麼,我做錯了什麼想法?任何指導將不勝感激。
<?php
if (isset($_POST['submitted'])){
session_start();
require_once 'CallerService.php';
/**
* Get required parameters from the web form for the request
*/
$paymentType =urlencode($_POST['paymentType']);
$firstName =urlencode($_POST['firstName']);
$lastName =urlencode($_POST['lastName']);
$creditCardType =urlencode($_POST['creditCardType']);
$creditCardNumber = urlencode($_POST['creditCardNumber']);
$expDateMonth =urlencode($_POST['expDateMonth']);
// Month must be padded with leading zero
$padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT);
$expDateYear =urlencode($_POST['expDateYear']);
$cvv2Number = urlencode($_POST['cvv2Number']);
$address1 = urlencode($_POST['address1']);
$address2 = urlencode($_POST['address2']);
$city = urlencode($_POST['city']);
$state =urlencode($_POST['state']);
$zip = urlencode($_POST['zip']);
$countrycode = urlencode($_POST['countrycode']);
$amount = urlencode($_POST['amount']);
//$currencyCode=urlencode($_POST['currency']);
$currencyCode="USD";
$paymentType=urlencode($_POST['paymentType']);
/* Construct the request string that will be sent to PayPal.
The variable $nvpstr contains all the variables and is a
name value pair string with & as a delimiter */
$nvpstr="&PAYMENTACTION=$paymentType&AMT=$amount&CREDITCARDTYPE=$creditCardType&ACCT=$creditCardNumber&EXPDATE=". $padDateMonth.$expDateYear."&CVV2=$cvv2Number&FIRSTNAME=$firstName&LASTNAME=$lastName&STREET=$address1&CITY=$city&STATE=$state".
"&ZIP=$zip&COUNTRYCODE=$countrycode&CURRENCYCODE=$currencyCode";
/* Make the API call to PayPal, using API signature.
The API response is stored in an associative array called $resArray */
$resArray=hash_call("doDirectPayment",$nvpstr);
/* Display the API response back to the browser.
If the response from PayPal was a success, display the response parameters'
If the response was an error, display the errors received using APIError.php.
*/
$ack = strtoupper($resArray["ACK"]);
if($ack!="SUCCESS") {
$_SESSION['reshash']=$resArray;
$location = "APIError.php";
header("Location: $location");
} elseif ($ack =="SUCCESS") {
echo '<h1>Thank you</h1>';
}
}
else {
// Display Form
}
?>
<form method="POST" id="donate" action="" name="DoDirectPaymentForm">
<!--Payment type is <?=$paymentType?><br> -->
<input type=hidden name=paymentType value="<?php echo $paymentType?>" >
<fieldset>
<div>
<label class="label">First Name:</label>
<input type=text size=36 maxlength=32 name=firstName class="required" value=John>
</div>
</div>
<input type="hidden" name="submitted" value="1">
<input type=Submit value=Submit>
</div>
非常感謝你們。很有幫助。現在完美運作。現在我的挑戰是要把我的工作,並使其在Wordpress中的所有功能。任何人有任何經驗在Wordpress中集成PHP表單處理程序? – 2011-01-28 18:07:55