I’ve just moved over from shared to dedicated hosting, and suddenly POST is not working. The variables are being sent according to firebug
jquery....min.js (line 4)
HeadersPostResponseHTML
Parametersapplication/x-www-form-urlencoded
current_subtab_1 0
current_tab_1 0
delivery_options Standard (5 working days)
new_copies 1500
p_binding Portrait
p_colours_fs Full Colour. (CMYK Process)
p_colours_fs_c No Lamination
p_colours_t Full Colour. (CMYK Process)
p_copies 1000
p_cover Self Cover
p_cover_c Silk
p_format A4 (Portrait Only)
p_pages 8
p_paper 130 GSM, coated
p_paper_type Silk
Source
current_tab_1=0¤t_subtab_1=0&delivery_options=Standard+(5+working+days)& p_copies=1000&p_paper=130+GSM%2C+coated&p_paper_type=Silk&p_colours_t=Full+Colour.+(CMYK+Process)&p_pages=8&p_binding=Portrait&p_format=A4+(Portrait+Only)&p_cover=Self+Cover
But when I turn on error reporting on the server side, it says all variables are undefined. Yes they are defined correctly and the scripts worked fine before…
<br />
<b>Notice</b>: Undefined index: current_tab_1 in <b>calculate.php</b> on line <b>6</b><br />
<br />
<b>Notice</b>: Undefined index: current_tab_1 in <b>calculate.php</b> on line <b>215</b><br />
<br />
<b>Notice</b>: Undefined index: current_subtab_1 in <b>calculate.php</b> on line <b>216</b><br />
<br />
<b>Notice</b>: Undefined index: p_format in <b>calculate.php</b> on line <b>220</b><br />
etc
So why is it doing this? Is there something I need to changed (a php.ini, config) setting? It must be a PHP thing
UPDATE:
I did a print_r($_POST); to see if anything is being posted and it returned an empty array
EDIT:
client side
if (current_tab == 0) {
if (current_subtab == 0) {
if ($("#saddle_brochure_copies").val() != "Please select...") {
if ($("#saddle_brochure_copies").val().match('^(0|[1-9][0-9]*)$')) {
if ($("#saddle_brochure_copies").val() != 25000) {
var new_copies = $('#saddle_brochure_copies option:selected').next().val(); //get next selected option for offer price
}
var p_copies = $("#saddle_brochure_copies"),
p_paper = $("#saddle_brochure_paper"),
p_paper_type = $("#saddle_brochure_paper_type"),
p_colours_t = $("#saddle_brochure_colours_t"),
p_pages = $("#saddle_brochure_pages"),
p_binding = $("#saddle_brochure_binding"),
p_format = $("#saddle_brochure_format"),
p_cover = $("#saddle_brochure_cover"),
p_cover_c = $("#saddle_brochure_cover_c"),
p_colours_fs = $("#saddle_brochure_colours_fs"),
p_colours_fs_c = $("#saddle_brochure_colours_fs_c"),
allFields = $([]).add(p_copies).add(p_paper).add(p_paper_type).add(p_colours_t).add(p_pages).
add(p_binding).add(p_format).add(p_cover).add(p_cover_c).add(p_colours_fs).add(p_colours_fs_c),
tips = $(".validateTips");
$.post("order/calculate.php", {
current_tab_1: current_tab,
current_subtab_1: current_subtab,
delivery_options: delivery_options.val(),
p_copies: p_copies.val(),
p_paper: p_paper.val(),
p_paper_type: p_paper_type.val(),
p_colours_t: p_colours_t.val(),
p_pages: p_pages.val(),
p_binding: p_binding.val(),
p_format: p_format.val(),
p_cover: p_cover.val(),
p_cover_c: p_cover_c.val(),
p_colours_fs: p_colours_fs.val(),
p_colours_fs_c: p_colours_fs_c.val(),
new_copies: new_copies
}, function (data) {
var resultArray = eval('(' + data + ')');
checkIfNull();
$(".value_2").append("£");
if ($("#hf_quote").val() != null) {
$("#hf_quote").val(null);
}
$("#hf_quote").val(resultArray[0]);
if ($("#hf_vat").val() != null) {
$("#hf_vat").val(null);
}
$("#hf_vat").val(resultArray[1]);
cashFlow($('.value'), 0, resultArray[0], 1 * 1000, 0);
if (resultArray[1] != "No VAT on this product!") {
$("#quote_vat").append("£", resultArray[1], " Inc. VAT");
} else {
$("#quote_vat").append(resultArray[1]);
}
if (resultArray[2]) {
if ($("#quote_offer").text() != null) {
$("#quote_offer").text("");
}
$("#quote_offer").append("Get ", new_copies, " copies for £", resultArray[2]);
}
});
print_r($_REQUEST); returns –
Array (
[ppRemember] => 35iq0m8oi3ldr1f8603sifpv52 [__utma] => 201771013.995365705.1339148067.1339148067.1339155188.2 [__utmc] => 201771013 [__utmz] => 201771013.1339148067.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none) [__utmb] => 201771013.9.10.1339155188
)
print_r($_GET); returns empty array
server side code in question
if ($_POST['current_tab_1']==0) {
if ($_POST['current_subtab_1']==0) {
//for saddle stitched brochures
//cost 1
$format = strip_tags(substr($_POST['p_format'],0,100)); //format
$B = strip_tags(substr($_POST['p_copies'],0,10)); //copies
$C1 = strip_tags(substr($_POST['p_paper'],0,100)); //paper inner pages
$C2 = strip_tags(substr($_POST['p_cover'],0,100));
$lamination = strip_tags(substr($_POST['p_colours_fs_c'],0,100)); //lamination
$P = strip_tags(substr($_POST['p_pages'],0,100));
$new_copies = strip_tags(substr($_POST['new_copies'],0,100));
}
}
UPDATE:
I tried echo $_POST[‘current_tab_1’]; right at the top of script and it returned an undefined error.
Also noticed one of the errors is this…?
Fatal error: Call to undefined function json_encode() in calculate.php on line 975
which is a built in function.. right?
found out why everything wasn’t working. Tried updating my server from 5.1.6 to 5.3 using plesk control panel, which ended up breaking halfway through the installation. When I finally got it working again I reverted back to 5.1.6 and decided to do the update another time. I presume it messed up my php installation, because after I updated to 5.3 successfully, everything started working again.