I'm building a one-page checkout for a customer of ours. This checkout is supposed to contain all forms for credentials, shipment and payment. Editing previously entered values should also be possible. This is all going fine except for one thing.
My page is built of multiple includes:
In each of these includes I check if the concerning data is in the session and if it is I show a different view. Nothing special here.
For example:
<?php
if (is_array($_SESSION['credentials'])) {
... show filled in values ...
} else {
... show form ...
}
?>
When values are already set, I also show an edit button. I do this as follows:
<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>
Followed by:
<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>
In the credentials include I check for the $_POST['edit']
. If it is set, i will show the form again with the customer's previously filled in data in the input fields.
Whenever I click the edit button the first time, it throws me a Connection was reset
browser error. If I refresh the page, it will ask for me to submit the form again. When I do this the error is gone. I can't seem to figure out where this is coming from. I checked the server logs but there is nothing unusual there.
*Note: * The same problem occurs between the shipment and payment steps.
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]
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;
Tamper Data
plugin for firefox to check the POST
data. (Nothing strange here either)I found something in my code I skipped when checking everything last time. This could however have something to do with my problem.
<script type="text/javascript">
window.history.forward();
function noBack() {
window.history.forward();
}
</script>
</head>
<body onload="noBack();" onpageshow="if (event.persisted) noBack();" onunload="">
/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
"Connection was reset"
Can sometimes mean a php crash. Without seeing the exact files it's hard to guess if and why this is happening.
Make sure to check the error_log, type: php --info | grep error to see what file it's being logged to (if you are on linux/unix).
My guess is a stray break; statement somewhere see this answer for a possible cause: https://stackoverflow.com/a/20036720/988324
You would find some trace of this in your error logs though. If you can provide this I might be able to help more.
is action="/checkout/payment/"
defined well?, i mean you could try abosolute url, i see a suspicious slash at the end /
, also you define form methods with method="POST"
, on index.php you should retrieve all with $_POST[]
dunno if this affect
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With