Jump to content

Unable to retrieve POST data from registration form


Go to solution Solved by Ch0cu3r,

Recommended Posts

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 by halben
<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?


  • Solution

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));
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.