halben Posted October 17, 2013 Share Posted October 17, 2013 (edited) Hi, I'm running into an issue retrieve data values from a registration submission form. The form is using a POST method Please see code below. More codes above, just a small snippet ... <div id="s2member-pro-paypal-registration-form-email-div" class="s2member-pro-paypal-form-div s2member-pro-paypal-registration-form-div s2member-pro-paypal-form-email-div s2member-pro-paypal-registration-form-email-div"> <label for="s2member-pro-paypal-registration-email" id="s2member-pro-paypal-registration-form-email-label" class="s2member-pro-paypal-form-email-label s2member-pro-paypal-registration-form-email-label"> <span><?php echo _x ("Email Address", "s2member-front", "s2member"); ?> </span><span class="red-asterik">∗</span><br /> </label> <input type="text" aria-required="true" data-expected="email" maxlength="100" autocomplete="off" name="s2member_pro_paypal_registration[email]" id="s2member-pro-paypal-registration-email" class="s2member-pro-paypal-email s2member-pro-paypal-registration-email" value="%%email_value%%" tabindex="40" /> </div> ... <div id="s2member-pro-paypal-registration-form-submit-div" class="s2member-pro-paypal-form-div s2member-pro-paypal-registration-form-div s2member-pro-paypal-form-submit-div s2member-pro-paypal-registration-form-submit-div"> %%hidden_inputs%% <!-- Auto-filled by the s2Member software. Do NOT remove this under any circumstance. --> <input type="submit" name="registration_submit" id="s2member-pro-paypal-registration-submit" class="s2member-pro-paypal-submit s2member-pro-paypal-registration-submit" value="<?php echo esc_attr (_x ("Register", "s2member-front", "s2member")); ?>" tabindex="400" /> </div> <div style="clear:both;"></div> </div> For this example, I have the following: // Store POST data into a variable $email = esc_attr($_POST['s2member_pro_paypal_registration[email]']); // Detect Submission if (!isset($_POST['registration_submit'])){ // Do nothing } else { // Check it var_dump($email); } This seems like it's correct but I wasn't able to retrieve the POST data and var_dump() was returning an empty string. Does anyone know why and should I post up more codes for more assistance? Thank you, Hal Edited October 17, 2013 by halben Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted October 17, 2013 Share Posted October 17, 2013 $_POST['s2member_pro_paypal_registration'] should be $_POST['s2member_pro_paypal_registration']['email'] Quote Link to comment Share on other sites More sharing options...
halben Posted October 17, 2013 Author Share Posted October 17, 2013 <input type="text" maxlength="100" autocomplete="off" value="" name="s2member_pro_paypal_registration[custom_fields][company_name]" id="s2member-pro-paypal-registration-custom-reg-field-company-name" aria-required="true" tabindex="105" data-expected="alphanumerics-5" class="s2member-pro-paypal-custom-reg-field-company-name s2member-pro-paypal-registration-custom-reg-field-company-name"> And the code above should be: $_POST['s2member_pro_paypal_registration[custom_fields][company_name]']; -> $_POST['s2member_pro_paypal_registration']['custom_fields']['company_name']; Can you please give me a quick explanation? Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted October 17, 2013 Solution Share Posted October 17, 2013 And the code above should be: $_POST['s2member_pro_paypal_registration[custom_fields][company_name]']; -> $_POST['s2member_pro_paypal_registration']['custom_fields']['company_name']; Yes. When you name a fields like foo[bar].The the $_POST becomes a multidimensional array. You can see how the $_POST is formatted using printf('<pre>%s</pre>', print_r($_POST, true)); Quote Link to comment Share on other sites More sharing options...
halben Posted October 17, 2013 Author Share Posted October 17, 2013 Thank you very much. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.