View Full Version : $_REQUEST Help to $_GET My Form $_POSTed

12-27-2010, 05:59 AM
Great forum! This looks like the place to be for PHP help. I'm a novice, but I've been muddling around in my Zen Cart store for over a year, so I probably know just enough to be dangerous.

I'm trying to create a mod related to gift certificates. More like face lift and expand on an old one. I'm ready to go except for one thing, a really silly thing, that I can't seem to resolve. Before you say, "Why aren't you asking them?" I did. Several times. Either no one knows or cares enough to impart their wisdom. I've searched high and low for a cure! Even here, with innumerable threads about very similar issues, nothing has yet to do the trick.

I didn't know it even had a name until I came across a remote blog post about "The Empty $_POST Bug." Which immediately made me feel better because at least I know I'm not crazy. Then I wanted to smack all of the people in the comments section who piped up with what had worked for them when none of it worked for me. I'm teasing, of course!

Code to follow below, including PHP form generation, relevant actions, and HTML output.

Here's the scenario: The script creates its own page, where the form will be located in the Info box. The form's goal is to enable bypassing of the gift certificate redemption process by allowing direct entry into the database of a new customer and the amount of "cash" they should have. The form consists of the email customer drop down, coded the same way as the regular "mail gift certificate" page where it came from, and a text input for the amount.

I have no trouble submitting the amount into the database. On the other hand, I can't get the customer selection from the drop down menu to be passed to the server even if I put it on a silver platter.

When the method of both code and form is set to post, I communicate with the server, but it only recognizes the amount. When everything is on get, I can see the URL values in my address bar, but they won't pass to the server. It's like the lights are on, but no one will answer the door. $_REQUEST does nada too.

I've tried using java a multitude of ways to no avail. I've tried so many things I'm not even sure I can remember them all, from crafty inputs to additional form controls, storing in sessions, trying to get "the get" and decode it afterward, changing/decoding the charset, file_get_content, more functions, moving the action to a different page, even checking my php.ini file for recommendations from the blog post. NOTHING has worked. It would seem I'm not coding correctly except the same thing happens when I create a "dummy" menu by hand using only HTML.

Pretty sure I'm the dummy here, which doesn't help when I'm so lost and frustrated I could scream. Praying one of you wise folk will have the cure!

PHP Form - Info Box Arrays

$heading = array();
$contents = array();
switch ($_GET['action']) {

case 'new':

$heading[] = array('text' => '<b>' . TEXT_GV_NEW . '</b>');
$heading[] = array('text' => TEXT_GV_NEW_CUSTOMER);

$customers = get_audiences_list('email');

$contents = array('form' => html_entity_decode(zen_draw_form('mail" enctype="multipart/form-data', FILENAME_GV_ADMIN_CASH_MGR, 'action=addnew', 'post')));
$contents[] = array('text' => html_entity_decode(zen_draw_pull_down_menu('customers_email_address', $customers) . '<input type="submit" value="" style="display: none"><input type="hidden" name="customers_email_address" value="'. $customers_email_address .'">'));
$contents[] = array('align' => 'left', 'text' => '<br>' . TEXT_GIFT_VOUCHER_NEW_AMOUNT . '<br>' . zen_draw_input_field('amount', number_format(0.00, 2, '.', '') ));
$contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_update.gif', IMAGE_UPDATE) . '&nbsp;<a href="' . zen_href_link(FILENAME_GV_ADMIN_CASH_MGR) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
break;Form Action - Add New

$action = (isset($_GET['action']) ? $_GET['action'] : '') or (isset($_POST['action']) ? $_POST['action'] : '');

if (zen_not_null($action)) {
switch ($action) {

case 'addnew':
$customers_email_address = $_POST['customers_email_address'];
$customer_select = $db->Execute("select 'customers_id' from " . TABLE_CUSTOMERS . " where 'customers_email_address' = '" . $customers_email_address . "' and 'customers_id' = '" . (int)$customers_id . "'");
$customers_id = zen_db_prepare_input($_POST['customer_select']);
$amount = zen_db_prepare_input($_POST['amount']);

// needs input customer and amount
if ($customers_id =="") {
$messageStack->add_session(ERROR_CUSTOMER_NOT_SELECTED, 'error');
if ($amount == 0.00) {
$messageStack->add_session(ERROR_AMOUNT_NOT_SELECTED, 'error');
if ($customers_id =="" or $amount == 0.00) {
zen_redirect(zen_href_link(FILENAME_GV_ADMIN_CASH_MGR, 'page=' . $_GET['page'] . '&action=new'));

// say adios if customer is already in the register
$gv_existing = $db->Execute("select customer_id from " . TABLE_COUPON_GV_CUSTOMER . "
where customer_id = '" . (int)$customers_id . "' ");

if ($gv_existing->RecordCount() > 0) {
$messageStack->add_session(ERROR_CUSTOMER_EXISTS . $customers_id , 'error');
} else {
// add new customer record
$insert_query = $db->Execute("insert into " . TABLE_COUPON_GV_CUSTOMER . "
(customer_id, amount)
values ('" . zen_db_input((int)$customers_id) . "', '" . (float)zen_db_input($amount) . "')");

// check for successful creation
$gv_existing = $db->Execute("select customer_id from " . TABLE_COUPON_GV_CUSTOMER . "
where customer_id = '" . (int)$customers_id . "' ");

if ($gv_existing->RecordCount() > 0 and $gv_existing->fields['customer_id'] == $customers_id and $gv_existing->fields['amount'] > 0) {
$messageStack->add_session(SUCCESS_VOUCHER_ADDED . (int)$customers_id . '$'.number_format($amount, 2, '.', ',') , 'success');
} else {
$messageStack->add_session(ERROR_VOUCHER_NOT_ADDED, 'error');
zen_redirect(zen_href_link(FILENAME_GV_ADMIN_CASH_MGR, 'page=' . $_GET['page'] . '&gid=' . $customers_id));
break;HTML Form Output

<!-- HEADER -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<html dir="ltr" lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>My Store Admin</title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<script language="javascript" src="includes/menu.js"></script>
<script type="text/javascript">
<!-- INFO BOX -->
<td width="25%" valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr class="infoBoxHeading">
<td class="infoBoxHeading"><b>Add New Gift Certificate Balance</b></td>
<tr class="infoBoxHeading">
<td class="infoBoxHeading">Select a Customer from the Menu:</td>
<form name="mail" enctype="multipart/form-data" action="https://mystore.com/admin/gv_admin_cash_manager.php?action=addnew" method="post">
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<td class="infoBoxContent"><select rel="dropdown" name="customers_email_address">
<option value="" selected="selected">Please Select</option>
<option value="customernameabc@msn.com">LName, FName (customernameabc@msn.com)</option>
<option value="customername123@gmail.com">LName, FName (customername123@gmail.com)</option>
<option value="customernamexyz@yahoo.com">LName, FName (customernamexyz@yahoo.com)</option>
<input type="submit" value=""><input type="hidden" name="customers_email_address" value=""></td>
<td align="left" class="infoBoxContent"><br>New Gift Certificate Available Balance:<br><input type="text" name="amount" value="0.00" /></td>
<td align="center" class="infoBoxContent"><br><input type="image" src="https://mystore.com/admin/includes/languages/english/images/buttons/button_update.gif" border="0" alt="Update" title=" Update ">&nbsp;<a href="https://mystore.com/admin/gv_admin_cash_manager.php"><img src="https://mystore.com/admin/includes/languages/english/images/buttons/button_cancel.gif" border="0" alt="Cancel" title=" Cancel "></a></td>

12-27-2010, 08:11 AM
How does your url look like after form submit?

12-27-2010, 09:13 AM
Hi, abduraooft

When on post, like this:

https://mystore.com/admin/gv_admin_cash_manager.php?page=&action=newAfter it returns me from the server, back to the form, with the error message that I have to choose a customer.

When on get, like this:

https://mystore.com/admin/gv_admin_cash_manager.php?customers_email_address=soandso%40gmail.com&amount=100.00&x=28&y=6But nothing happens. No error message, no database entry, it just sits there in the browser.

Okay, this is weird. The link is chopping off in my post, even though I can see it in my browser status bar. Where, interestingly, it's been decoded back into character. If only my site would do that!! LOL

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum