Home: Perl Programming Help: Beginner:
Need help with POST



aakash
New User

Oct 4, 2008, 4:39 PM


Views: 1440
Need help with POST

I am trying to write a perl script that will select a product to shop from a website, enter quantity, add to cart and checkout. I have been able to select the product but i am not able to submit the 'add to cart'. The 'add to cart' is an image instead of a button. I am using POST but it is not working. Here is part of the code i am using:

my $url = "http://www.xyz.com/shop/index.php?main_page=products&cPath=2&prod_no=1;
my $browser = LWP::UserAgent->new;
resp = $browser->post($url,
['Cart_Qty' => 'form.submit()']);

Section of the HTML code:
<form name="Cart_Qty" action="http://www.xyz.com/shop/index.php?main_page=products&amp;cPath=2&amp;prod_no=1&amp;action=add_product" method="post" enctype="multipart/form-data">

<div id="cartAdd">
Add to Cart: <input type="text" name="Cart_Qty" value="1" maxlength="6" size="4" /><br /><br /><input type="hidden" name="prod_no" value="8" /><input type="image" src="includes/templates/template_default/buttons/english/button_in_cart.gif" alt="Add to Cart" title=" Add to Cart " /> </div>

Appreciate any help with this. Thanks!


sycoogtit
User

Oct 6, 2008, 5:56 AM


Views: 1391
Re: [aakash] Need help with POST

That sounds like a scary script. Why are you doing that?

Without putting this into emacs and trying to debug it myself, the only thing that jumps out at me is you have two HTML elements named Cart_Qty. That could cause problems.

--
http://bunsooter.com


KevinR
Veteran


Oct 6, 2008, 9:45 AM


Views: 1388
Re: [sycoogtit] Need help with POST

mixing POST and GET data and javascript to boot? Yikes.
-------------------------------------------------