Hi seniors.
i have a weird problem haunting me for weeks
everrything runs well when i use get method to fetch the from data . while it meet two problems when i try to change form method to "post"
1. i have to uncomment #Links::init_user(); or it will show you timeout
2. after uncomment #Links::init_user(); it runs ok while produce timeout again when i try to run a sub routine.
Could you one light me a bit what is the exact problem i have. as i have try to fix it for weeks in vain.
here is scirpts test.cgi
#!/usr/bin/perl
### cookie content. you could copy it to the cookie## $D = {_SESSION_ID => '3d1cef209379994ec50edca13cdd37a6',_SESSION_ATIME => 1247471428,CART => [{name => 'product3name',quantity => 1,price => 33,itemID => '1003',prod_subtotal => 33}],_SESSION_REMOTE_ADDR => '127.0.0.1',_SESSION_EXPIRE_LIST => {},_SESSION_CTIME => 1247471352};
use CGI::Session;
use Data::Dumper;
use CGI;
use lib 'D:\webtest\merchant\linkcart\admin';
use Links qw/:objects/; # or whatever $IN, $DB, $CFG, $USER etc...
use Links qw/$USER/;
Links::init('D:\webtest\links\admin'); #########################
#Links::init_user(); # gets the user information
use Links::SiteHTML; # if your using templates
############
my $cgi = new CGI;
my $session = new CGI::Session(undef, $cgi, {Directory=>'c:/tmp/carttmp'});
#### change the directory as per needs
print $session->header();
############
my $itemIDnum = $cgi->param('itemIDnum') || 1;
my $itemID = $cgi->param('itemID') || 1;
my $name = $cgi->param('name') || 1;
my $price = $cgi->param('price') || 1;
my $quantity = $cgi->param('quantity') || 1;
my $cmd = $cgi->param('cmd') || 1;
if ( $cmd eq "display" ) {
print display_cart($cgi, $session);
} elsif ( $cmd eq "add" ) {
# print add_item($cgi, $session, \%products,);
#print " Oops! Error<br><br>$cmd<br>$name $itemIDnum $price $quantity <br>\n";
print display_cart($cgi, $session);
# print " testtesttest<br><br>$cmd<br>$name $itemIDnum $price $quantity <br>\n";
} elsif ( $cmd eq "remove") {
print remove_item($cgi, $session);
} elsif ( $cmd eq "clear" ) {
print clear_cart($cgi, $session);
} elsif ( $cmd eq "update" ) {
print update_cart($cgi, $session);
} else {
print display_cart($cgi, $session);
}
sub display_cart {
my ($cgi, $session,$product,$tags) = @_;
# getting the cart's contents
my $tags;
$tags->{total_price} = 0;
foreach my $product ( @{$session->param('CART')} ) {
$product->{prod_subtotal} = $product->{price} * $product->{quantity};
$tags->{total_price} += $product->{prod_subtotal};
$tags->{itemmaxtemp}=$itemmaxtemp;
$tags->{itemID}=$itemID;
push @{$tags->{cart_loop}}, $product;
}
print $cgi->header();
print Links::SiteHTML::display('8gtcart', $tags);
exit;
}
below are form i used to test it
###### it runs well when using get method. while it pruduce timeout when using post method , how to correct it?????
<FORM METHOD=get ACTION="test.cgi">
<input type="hidden" name="itemID" value="21">
<input type="hidden" name="name" value="ddd3">
<input type="hidden" name="cmd" value="add">
<BR><INPUT type="submit" value="Order Now">
</FORM>
<input type="hidden" name="itemID" value="21">
<input type="hidden" name="name" value="ddd3">
<input type="hidden" name="price" value="21">
<input type="hidden" name="cmd" value="add">