[英]Silex basic form submission
我正在嘗試將支付網關添加到我的網站。 Silex框架的基本實現給我帶來很多麻煩。 找不到app.php
頁面。 實際上,我當前正在使用測試服務器,並且signup.php
頁面位於以下目錄中:
http://localhost/www/smafo/signup.php
,
提交表單最終導致以下URL http://localhost/create_transaction
,從而導致頁面未找到錯誤。
注意:將表單的action屬性更改為app.php
,路由到正確的app.php
頁面,並導致Symfony Page not found錯誤。
有什么想法我在這里做錯了嗎?
這是示例表單: signup.php
<form action="/create_transaction" method="POST" id="braintree-payment-form">
<p>
<label>Card Number</label>
<input type="text" size="20" autocomplete="off" data-encrypted-name="number" />
</p>
<p>
<label>CVV</label>
<input type="text" size="4" autocomplete="off" data-encrypted-name="cvv" />
</p>
<p>
<label>Expiration (MM/YYYY)</label>
<input type="text" size="2" data-encrypted-name="month" /> / <input type="text" size="4" data-encrypted-name="year" />
</p>
<input type="submit" id="submit" />
</form>
這是我的app.php(與signup.php在同一目錄中)
$app = new Silex\Application();
$app->get('/', function () {
include 'signup.php';
return '';
});
$app->post('/create_transaction', function (Request $request) {
echo 'YES';
$result = Braintree_Transaction::sale(array(
'amount' => '1000.00',
'creditCard' => array(
'number' => $request->get('number'),
'cvv' => $request->get('cvv'),
'expirationMonth' => $request->get('month'),
'expirationYear' => $request->get('year')
),
'options' => array(
'submitForSettlement' => true
)
));
if ($result->success) {
return new Response("<h1>Success! Transaction ID: " . $result->transaction->id . "</h1>", 200);
} else {
return new Response("<h1>Error: " . $result->message . "</h1>", 200);
}
});
$app->run();
我非常感謝任何建議。
提前謝謝了!
我遇到了同樣的問題,最終通過進行以下替換來解決了這個問題:
<form action="app.php/create_transaction" method="POST" id="braintree-payment-form">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.