Buying from the BHH

Tpj_4000

Member
To qualify, I'm not very versed in web page coding. However, I dug through the BHH pane source code and came across:

Code:
Items for Sale:</b><table><form action=bhh.php method=post><input type=hidden name=action value="buy"

...

<input type=radio name=whichitem value=2464 ></td><td><img src="http://images.kingdomofloathing.com/itemimages/ccheese.gif"



So, as a test I try:

Code:
void main(){

	item it = $item[bowl of Bounty-Os];
        int itemNum = it.to_int();

	print("item number: " + itemNum);

	string bhh_page = visit_url("bhh.php?pwd&action=buy&whichitem=" + itemNum);

}

Can someone explain why this doesn't work?
 

lostcalpolydude

Developer
Staff member
The form uses a POST request. You need to use the two-parameter version of visit_url here, and the second parameter is true. Assuming everything else is correct, anyway.
 

Bale

Minion
The form uses a POST request. You need to use the two-parameter version of visit_url here, and the second parameter is true. Assuming everything else is correct, anyway.

I had thought that the one parameter version of visit_url() is the same as the two parameter with the second parameter true. Is there some difference? I had thought that the only difference between the two versions is that if you set the second parameter to false it will use a GET request.
 

mredge73

Member
You may need to do some more experimenting, I think your problem may be associated to the text box and you have to supply it with a number.

A few suggestions to try:

bhh.php?&action=buy&whichitem=" + itemNum +"&howmany=1&pwd
bhh.php?&action=buy&whichitem=" + itemNum +"&howmany=1&pwd
bhh.php?pwd&action=buy&whichitem=" + itemNum +"&howmany=1&submit=Buy Item
 

Tpj_4000

Member
mredge73 was absolutely correct. I was missing &howmany= .Digging through the code even more, the very tail end was:

Code:
<input class=button type=submit value="Buy Item"> <input class=text type=text name=howmany size=2 value=1></center></form>

I find it strange though that it didn't appear at the beginning. In any case, this worked:
Code:
        item it = $item[bowl of Bounty-Os];
        int itemNum = it.to_int();

	print("item number: " + itemNum);

	string bhh_page = visit_url("bhh.php?pwd&action=buy&whichitem=" + itemNum + "&howmany=1");
 

Theraze

Active member
Or if you want it be be a bit easier, you could skip the last + by putting the &howmany earlier... like this:
Code:
        item it = $item[bowl of Bounty-Os];
        int itemNum = it.to_int();

	print("item number: " + itemNum);

	string bhh_page = visit_url("bhh.php?pwd&action=buy&howmany=1&whichitem=" + itemNum);
 
Top