I just love talking to myself. :)
After much trial and error, PHP tutorials and head banging, I've arrived at one certain conclusion - I need glasses. LOL! No wonder the token echo didn't work for me. ;)
The problem with my form seems to be something to do with its method. Which explains why I finally saw the customer's email address in my browser, even though the method had been set to post. Broken HTML with the method chopped reverted to get. Makes sense.
What isn't making sense is that I still can't get the customer selection to be recognized. I've tried a million combinations of methods, code, functions, Javascript, no Javascript, all with the same result. When the method is post, I communicate with the server, but only the amount is recognized. When the method is get, I can see the customer email address has indeed been selected, but I get zero communication with the server. However, that illustrated another issue, where the customer email address has been encoded so the "@" sign has been replaced with its ASCII equivalent, "%40".
Being I can't see what's being passed when the method is post, I have to assume the customer email address is being passed the same way as get. So I tried another hundred ways to change the ASCII back into the symbol. Doesn't seem anything is working because I get the same old thing, no customer selected. I've tried to make sure my forms (both <form> and <select>) each have different IDs and names (four different values to avoid confusion), the methods are correct (I got tired of switching back the retrieval code so now it's just set to request LOL!) and so is the form HTML. I had mentioned breaking apart the inherent Zen forms, which is what I'm using because it's easier for me to follow. I should also mention I get the same result using the native code. Clearly the token was the least of my problems. LOL!
This is for a pretty cool mod I'm going to share, if that helps to know, so I hope someone can take a look and point out the dumb thing I must be doing. This code rendition includes onchange, which shouldn't be needed, just so you can see I'm not crazy. Green, yes, absolutely - crazy, no. Even if I do talk to myself. ;)
PHP form:
PHP Code:
$customers = get_audiences_list('email');
$contents = array('form' => zen_draw_pre_form('email', 'clist', zen_href_link(FILENAME_ACTION, '&action=addnew')) . html_entity_decode(zen_draw_pull_down_menu('customers_email_address" id="cmail" onchange="document.email.customers_email_address.value=this.value', $customers) . zen_draw_post_form($zentoken) . '<input type="hidden" name="customers_email_address" value=""><input type="submit" value="" style="display: none">'));
$contents[] = array('align' => 'left', 'text' => '<br>' . TEXT_NEW_AMOUNT . '<br>' . zen_draw_input_field('amount', number_format($gInfo->amount, 2, '.', '') ));
$contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_insert.gif', IMAGE_INSERT) . ' <a href="' . zen_href_link(FILENAME_ACTION, 'page=' . $_GET['page'] . '&gid=' . $customers->customers_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
HTML form output:
Code:
<td width="25%" valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr class="infoBoxHeading">
<td class="infoBoxHeading"><b>Title</b></td>
</tr>
<tr class="infoBoxHeading">
<td class="infoBoxHeading">Select a Customer from the Menu:</td>
</tr>
</table>
<form id="clist" name="email" action="https://mystore.com/admin/action.php?&action=addnew" method="post"><select rel="dropdown" name="customers_email_address" id="cmail" onchange="document.email.customers_email_address.value=this.value">
<option value="" selected="selected">Please Select</option>
<option value="[email protected]">Last Name, First Name ([email protected])</option>
<option value="[email protected]">Last Name, First Name ([email protected])</option>
<option value="[email protected]">Last Name, First Name ([email protected])</option>
</select>
<input type="hidden" name="securityToken" value="1234567890987654321" /><input type="hidden" name="customers_email_address" value=""><input type="submit" value="" style="display: none">
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td align="left" class="infoBoxContent"><br>Input Amount:<br><input type="text" name="amount" value="0.00" /></td>
</tr>
<tr>
<td align="center" class="infoBoxContent"><br><input type="image" src="includes/languages/english/images/buttons/button_insert.gif" border="0" alt="Insert" title=" Insert "> <a href="https://mystore.com/admin/action.php?page=1"><img src="includes/languages/english/images/buttons/button_cancel.gif" border="0" alt="Cancel" title=" Cancel "></a></td>
</tr>
</table>
</form>
PHP retrieval:
PHP Code:
$email_raw = $_REQUEST['customers_email_address'];
$customerwho = preg_replace('/%40/', '@', $email_raw); // preg_replace just happening to be the last of several filters and functions I've tried to get rid of the ASCII, including substr, iconv, html_entity_decode, urldecode, etc.
$customer_select = $db->Execute("select customers_id from " . TABLE_CUSTOMERS . " where customers_email_address = '" . $customerwho . "' and customers_id = '" . (int)$customers_id . "'");
$customers_id = zen_db_prepare_input($_REQUEST['customer_select']);
$amount = zen_db_prepare_input($_REQUEST['amount']);
Bookmarks