Hy friends!
I have one problem and i want help, please.
The problem in this script is in "sub add". I do not why when set the cookie don't write (in cookie)
$idCumparator:$denumire:$pret:$idAfiliat with : . When the cookie it's set, my line it's with ascii code
%3A . Why? I want to write set the cookie $idCumparator:$denumire:$pret:$idAfiliat with : not with ascii code . I want help. Thank you.
#!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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.