#!perl -w use CGI::Carp('fatalsToBrowser'); use CGI; use CGI::Cookie; use CGI; use DBI; use warnings; $query = CGI->new(); if ($query->param('product') eq "add"){ &add; } my $driver = "dbi:mysql:nx_db"; my $dbh = DBI->connect($driver, $userdb, $passworddb) or die "Error ($ +DBI:err): $DBI::errstr\n"; $statement = $dbh->prepare("SELECT id_produs, denumire, pret, url_demo +, descriere, url_download, foto, categorie FROM produse") or die "Err +or ($DBI:err): $DBI::errstr\n"; $statement->execute or die "Error ($DBI:err): $DBI::errstr\n"; print $query->header(-type=>'text/html'); while (($idProdus, $denumire, $pret, $urlDemo, $descriere, $urlDownloa +d, $foto, $catogorie) = $statement->fetchrow_array) { print <<ENDHTML; <table align=center border=0> <tr><td rowspan=3 align=center> <img src="$foto" border=0></td> <td><b>$denumire</b></td></tr> <tr><td> $descriere</td></tr> <tr><td align=right> Id product: $idProdus | Pret: $pret\$\ | <a href="$urlDemo">Try Demo!< +/a> | <a href="shop.pl?product=add&idp=$idProdus&title=$denumire&pric +e=$pret&ida=$ida">Add to Cart!</a> </td></tr></table> ENDHTML } $statement->finish; $dbh->disconnect; exit; print "Nu exista in baza de date <b>nx_db</b> nici un produs."; exit; sub add { my $idCumparator = $query->param('idc'); my $idProdus = $query->param('idp'); my $denumire = $query->param('title'); my $pret = $query->param('price'); my $idAfiliat = $query->param('ida'); my $list = "$idCumparator".":"."$denumire".":"."$pret".":"."$idAfiliat +"; my %cookie = CGI::Cookie->fetch; my $cookie = CGI::Cookie->new(-name=>$idProdus,-value=>$list); print header(-cookie=>$cookie); print "$idCumparator $idProdus $denumire $pret $idAfiliat<br>$ENV{'HTT +P_COOKIE'}"; exit; }
In reply to Cookie shop problem by webstudioro
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |