获取下拉菜单
我使用 Paypal 的“立即购买”按钮以及用 PHP 编写的 IPN 处理程序,以便在购买时向我发送电子邮件。电子邮件已正确发送并传递了大部分数据,但它没有捕获用于选择服装尺寸的下拉列表。
这是我的按钮代码字段:
<input type="hidden" name="item_name" value="Test Shirt">
<input type="hidden" name="item_number" value="001">
<input type="hidden" name="on0" value="sizes">
Select a size:
<select name="os0">
<option value="Small">Small </option>
<option value="Medium">Medium </option>
<option value="Large">Large </option>
<option value="Extra Large">Extra Large </option>
</select>
我的 PHP IPN 脚本将数据捕获到变量中,如下所示:
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$size = $_POST['on0'];
$sizeChoice = $_POST['os0'];
电子邮件正确显示项目名称和项目编号,但没有显示 $size 和 $sizeChoice 变量。已经很晚了,所以我确信我正在查看一些非常明显的东西,但我仍然想知道我是否只是调用错误或者我是否忘记了一些隐藏字段?
I'm using Paypal's buy it now buttons along with an IPN handler written in PHP to send me an e-mail whenever a purchase is made. The e-mail is properly being sent and is passing much of the data, but it's not capturing the drop down list for selecting a clothing item's size.
Here's my button code fields:
<input type="hidden" name="item_name" value="Test Shirt">
<input type="hidden" name="item_number" value="001">
<input type="hidden" name="on0" value="sizes">
Select a size:
<select name="os0">
<option value="Small">Small </option>
<option value="Medium">Medium </option>
<option value="Large">Large </option>
<option value="Extra Large">Extra Large </option>
</select>
My PHP IPN script that captures the data into variables looks like this:
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$size = $_POST['on0'];
$sizeChoice = $_POST['os0'];
The e-mail properly displays the item name and item number, but nothing for the $size and $sizeChoice variables. It's late so I'm sure I'm looking over something very obvious but am still wondering if I'm just calling it wrong or if I'm forgetting some hidden fields?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
今天也有同样的问题。不要使用 $_POST['os0'] 和 $_POST['on0'],而是使用 $_POST['option_selection1'] 和 $_POST['option_name1']
此页面显示选项,搜索“option_name1”:
获取下拉菜单
Had the same probelm today. Instead of using $_POST['os0'] and $_POST['on0'], use $_POST['option_selection1'] and $_POST['option_name1']
This page shows the options, search for "option_name1":
Getting drop down menu
变量名称区分大小写。使用 $_POST 而不是 $_post。
Variable names are case sensitive. Use $_POST instead of $_post.