开发者

How do I separate posted values from a form in PHP

开发者 https://www.devze.com 2022-12-30 02:02 出处:网络
how pass multiple values to paypal. I used 开发者_如何学Goit in paypal submission page <input type=\"hidden\" name=\"custom\" value=\"id_cart={$id_cart}&option={option}\" />

how pass multiple values to paypal. I used 开发者_如何学Goit in paypal submission page

<input type="hidden" name="custom" value="id_cart={$id_cart}&option={option}" />

I get

$_POST['custom'] = id_cart=534&option=1620850004 , 

how I get it separately like

 $_POST['id_cart'] =534 , $_POST['option'] =1620850004.


The name attribute on your form fields will become the key server-side, simply break your current hidden field up with new names:

You should also be escaping the values on the page, I'm assuming you're using smarty...


<input type="hidden" name="id_cart" value="{$id_cart|htmspecialchars}" />
<input type="hidden" name="option" value="{$option|htmspecialchars}" />

If you want / need to keep your HTML the same, you can split the values on the server-side with parse_str:


$r = array();
parse_str($_POST['custom'], $r);

print $r['id_cart'];
print $r['option'];


Assuming those values are stored in $id_cart and $option AND you really want a querystring-like parameter in your hidden field:

<input type="hidden" name="custom" value="custom={$id_cart}&option={$option}" />


you can also try this way

{php}
$value = 'custom='.{$id_cart}.'&option='.{$option}
{/php}

use this "$value" into your hidden box


Can you please change the hidden control's name...? because the value which posted like "custom=" and the name is also have "custom"

so there may be some conjunctions..please change that and let ma know.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号