Pet*_*ter 5 javascript php forms .htaccess
我正在为我们的客户建立一页一页的结账.此结帐应包含凭据,发货和付款的所有表格.也应该可以编辑先前输入的值.这一切都很好,除了一件事.
我的页面由多个包含:
在每个包含中,我检查相关数据是否在会话中,如果是,我显示不同的视图.这里没什么特别的.
例如:
<?php
if (is_array($_SESSION['credentials'])) {
... show filled in values ...
} else {
... show form ...
}
?>
Run Code Online (Sandbox Code Playgroud)
当值已经设置时,我还会显示一个编辑按钮.我这样做如下:
<div class="left-column">
<h1 class="title-left">Step 1 - Credentials</h1>
<div class="pull-left" style="width: 50%;">
Name: name<br />
Address: Address 11<br />
Postal Code: 12345AA<br />
Country: Country<br />
</div>
<br />
<div style="clear: both;height: 10px;"></div>
<center>
<form method="POST" action="/checkout/credentials/">
<input type="hidden" name="edit" value="credentials">
<button class="sexybutton sexysimple sexybestel">Edit</button>
</form>
</center>
</div>
Run Code Online (Sandbox Code Playgroud)
其次是:
<div class="left-column">
<h1 class="title-left">Step 2 - Shipment</h1>
<i>Select a shipment method</i>
<form method="POST" action="/checkout/payment/">
<input type="radio" value="0" name="shipmentmethod"> Collect<br />
<input type="radio" value="1" name="shipmentmethod"> Deliver<br />
<input type="submit" value="Go to Step 3" class="sexybutton sexysimple sexybestel pull-right" name="shipment">
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
在凭证包括我检查$_POST['edit'].如果已设置,我将再次显示表单,其中客户先前已在输入字段中填入数据.
每当我第一次单击编辑按钮时,它会抛出一个Connection was reset浏览器错误.如果我刷新页面,它会要求我再次提交表单.当我这样做时,错误消失了.我似乎无法弄清楚这是从哪里来的.我检查了服务器日志,但没有什么不寻常的.
*注意:*出货和付款步骤之间出现同样的问题.
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
order allow,deny
allow from all
RewriteCond %{HTTP_HOST} ^tapijttegelhandel\.nl
RewriteRule ^(.*)$ http://www.tapijttegelhandel.nl/$1 [R=permanent,L]
AddDefaultCharset utf-8
RewriteRule ^checkout/ /index.php?mod=checkout&action=show [NC,L,QSA]
Run Code Online (Sandbox Code Playgroud)
case 'checkout':
$action = isset($_GET['action']) ? $_GET['action'] : '';
switch ($action) {
case 'completed':
# ...
break;
case 'cancelled':
# ...
break;
case 'credentials':
case 'shipment':
case 'payment':
case 'edit':
default:
include $_SERVER['DOCUMENT_ROOT'].'checkout/show.php';
break;
}
break;
Run Code Online (Sandbox Code Playgroud)
Tamper Data为firefox 安装了一个插件来检查POST数据.(这里也没什么奇怪的)我上次在检查所有内容时跳过了我的代码.然而,这可能与我的问题有关.
<script type="text/javascript">
window.history.forward();
function noBack() {
window.history.forward();
}
</script>
</head>
<body onload="noBack();" onpageshow="if (event.persisted) noBack();" onunload="">
Run Code Online (Sandbox Code Playgroud)
/cart GET 200 OK
/checkout/credentials/ GET 304 OK
/checkout/credentials/ POST 304 OK
# edit
/checkout/credentials/ POST - Error 'Connection was reset'
# Refresh
/checkout/credentials/ POST 200 OK
Run Code Online (Sandbox Code Playgroud)
“连接已重置”
有时可能意味着 php 崩溃。如果没有看到确切的文件,很难猜测是否以及为什么会发生这种情况。
确保检查 error_log,输入: php --info | grep error 来查看它被记录到哪个文件(如果您使用的是 linux/unix)。
我的猜测是一次偶然的休息;某处的声明可能会导致此答案:https ://stackoverflow.com/a/20036720/988324
不过,您会在错误日志中找到一些痕迹。如果您能提供这个,我也许可以提供更多帮助。
| 归档时间: |
|
| 查看次数: |
1817 次 |
| 最近记录: |