Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 7th, 2004, 1:41 PM   #1
eggsy
Newbie
 
Join Date: Dec 2004
Posts: 5
Rep Power: 0 eggsy is on a distinguished road
Hi all much help needed??

I have had to develop a site in Perl that acts as a very basic e-commerce system whihc tracks items ordered in Cookies.

Code for adding cookies is shown below:

$cookie_value = $query->cookie('cycle');
#cookie value is called 'cycle'

$cycle_to_add = $query->param('cycleid');

if ($cookie_value)
{

$cookie_value = $cookie_value . ',';

}


$cookie_value = $cookie_value . $cycle_to_add;


$cookie_to_set = $query->cookie (-name => 'cycle',

-value => $cookie_value,

-expires=> '',

-path=> '/');

print $query->header(-cookie => $cookie_to_set);[/b]

What I am also looking to do is make it so that people can remove items from their shopping basket?
and having real problems in how to go about this.

Code for area of the shopping basket is shown below:

$sql = qq{SELECT name FROM stock WHERE item_id = ?};



$sth = $dbh -> prepare($sql);



@cycle_list = split /,/, $cookie_value;

print "<FORM METHOD=post ACTION=\"redirect.pl\">\n\n";
print "<CENTER><FONT FACE = \"arial, helvetica, sans\"><TABLE COLS=3>";


foreach $cycleid (@cycle_list)
{



$sth -> execute($cycleid);



($name) = $sth->fetchrow_array;



print "<TR><TD>$name</TD><TD></TD><TD><A HREF=remProduct.pl?id=$cycleid>REMOVE</A></TD></TR>\n";

}

print "</TABLE>\n";[/b]

So it will pass the Cycle ID to the remProduct Perl file I just dont know where to go from there?

If anyone can help would be really useful thanks all for reading, any more info needed please let me know??
eggsy is offline   Reply With Quote
Old May 2nd, 2005, 11:48 AM   #2
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 314
Rep Power: 4 mackenga is on a distinguished road
Can't really make out your code very well because of the invasion of smilies; maybe I'd get a better look at it if you wrapped it up in code tags.

It may not be necessary, though, if this answer is good enough. If I get the gist and you're just wondering how to clear a cookie using CGI.pm, I'm pretty sure it's the same as setting one, but you set its value to undef.

Like I say, I'm pretty sure this will work. Alternatively, how about setting it, but setting its expiry time to now?
mackenga is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:49 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC