POST 修身和修身 PHP
POST Form & Slim PHP
我希望有人能帮助我。我已经安装并运行了 Slim。问题是我有一个提交到路由 URL 的 HTML 表单,它显示“找不到 404 页面”,但如果我手动转到此页面而不提交表单,它工作正常。如果我使用 GET,它在提交表单时也能正常工作。
我在 /store 路由上的表单
<form action='../checkout/demo' method='POST'>
<input name='fullname' id='fullname' type='text' placeholder='Fullname'>
<input name='email' placeholder='Email Address' type='text'>
<input name='address1' placeholder='Address' type='text'>
<input name='city' placeholder='City' type='text'>
<input name='state' placeholder='State' type='text'>
<input name='zip' placeholder='Zip/Postal Code' type='text'>
<button type='submit'>Pay for my Items Now!</button>
</form>
我的路由器
require "Slim/Slim.php";
\Slim\Slim::registerAutoloader();
$router = new \Slim\Slim();
$router->get("/store/:storeUrl", function ($storeUrl) {
//This just adds the form to this url
$controller = new Controller();
$controller->mainStore($storeUrl);
});
$router->get("/checkout/:storeUrl", function ($storeUrl) use ($router) {
echo "string";
});
$router->run();
如有任何帮助,我们将不胜感激!
感谢大家的帮助!
我只是通过更改使其工作:
$router->get("/checkout/:storeUrl", function ($storeUrl) use ($router) {
echo "string";
print_r($_POST);
});
至
$router->post("/checkout/:storeUrl", function ($storeUrl) use ($router) {
echo "string";
print_r($_POST);
});
Slim php 正在从表单中寻找 GET 而不是 post。
我希望有人能帮助我。我已经安装并运行了 Slim。问题是我有一个提交到路由 URL 的 HTML 表单,它显示“找不到 404 页面”,但如果我手动转到此页面而不提交表单,它工作正常。如果我使用 GET,它在提交表单时也能正常工作。
我在 /store 路由上的表单
<form action='../checkout/demo' method='POST'>
<input name='fullname' id='fullname' type='text' placeholder='Fullname'>
<input name='email' placeholder='Email Address' type='text'>
<input name='address1' placeholder='Address' type='text'>
<input name='city' placeholder='City' type='text'>
<input name='state' placeholder='State' type='text'>
<input name='zip' placeholder='Zip/Postal Code' type='text'>
<button type='submit'>Pay for my Items Now!</button>
</form>
我的路由器
require "Slim/Slim.php";
\Slim\Slim::registerAutoloader();
$router = new \Slim\Slim();
$router->get("/store/:storeUrl", function ($storeUrl) {
//This just adds the form to this url
$controller = new Controller();
$controller->mainStore($storeUrl);
});
$router->get("/checkout/:storeUrl", function ($storeUrl) use ($router) {
echo "string";
});
$router->run();
如有任何帮助,我们将不胜感激!
感谢大家的帮助!
我只是通过更改使其工作:
$router->get("/checkout/:storeUrl", function ($storeUrl) use ($router) {
echo "string";
print_r($_POST);
});
至
$router->post("/checkout/:storeUrl", function ($storeUrl) use ($router) {
echo "string";
print_r($_POST);
});
Slim php 正在从表单中寻找 GET 而不是 post。