Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
No such thing as a small change
 
PerlMonks  

Re: Re: Re: form problem...

by Wonko the sane (Deacon)
on Feb 26, 2004 at 16:43 UTC ( #332039=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: form problem...
in thread form problem...

my %in = $cgi_obj->Vars; # where $cgi_obj is whatever your CGI object +is. my $hidden_fields; # This for loop goes through each of the dvdX keys and creates an HTML + hidden field for them, appending each to the string of others. $hidden_fields .= $cgi->hidden( $_, $in{$_} ) for ( grep { /dvdX/ } ke +ys %in ); print start_form(-action=>'show.pl'); print table( {border=>1, -width=>'35%', -align=>'center', -style=>'bor +der: ridge lime; color: yellow; font-size: 20', -background=>'../data +/images/blue.jpg'}, Tr( {-align=>'center'}, td( 'Movie X' ), td( popup_menu(-name=>' +dvdX', -values=>[@tips] )), td( submit( 'Pick' ))), Tr( {-align=>'center'}, td( submit( 'Clear' )), td( submit( ' +Done' )))), br(), br(); print table( {border=>1, -width=>'35%', -align=>'center', -style=>'bor +der: ridge lime; color: yellow; font-size: 20', -background=>'../data +/images/blue.jpg'}, Tr( {-align=>'center'}, td( submit( 'Add' )), td( submit( 'Sh +ow' ))), Tr( {-align=>'center'}, td( submit( 'Modify' )), td( submit( 'De +lete' )))); # this is the string that contains all of the generated HTML hidden fi +elds we just made. print $hidden_fields; print end_form(), br(), br();
If this still isnt making sense to you, then you should really take
some time to go over to tutorials available on this site. As already siggested by others :)

Best Regards,
Wonko


Comment on Re: Re: Re: form problem...
Download Code
Re: Re: Re: Re: form problem...
by Nik on Feb 26, 2004 at 17:20 UTC
    thanks man but it gives me an error!
    here is my code so far
    #!/usr/bin/perl -w use CGI::Carp qw(fatalsToBrowser); use CGI qw(:standard); use DBI; use DBD::mysql; use Mail::Sendmail; $xronos = scalar(localtime(time + 7200)); $xronos =~ s/:\d{2} \d{4}//g; $ip = $ENV{'REMOTE_ADDR'}; @numbers = split (/\./,$ip); $address = pack ('C4', @numbers); $host = gethostbyaddr ($address, 2) || $ip; print header( -charset=>'iso-8859-7' ); print start_html( -title=>'Ψυχωφελή Πνευματικά Κείμενα!', -background= +>'../data/images/night.jpg' ); $db = ($ENV{'SERVER_NAME'} ne '50free.net') ? DBI->connect('DBI:mysql:nikos_db', 'root', '') : DBI->connect('DBI:mysql:nikos_db:50free.net', 'nikos_db', 'macgyv +er') or print font({-size=>5, -color=>'Lime'}, $DBI::errstr) and exit 0; print p( {-align=>'center'}, font( {-size=>5, -color=>'Cyan'}, "- Ηλεκ +τρονική Παραγγελία Ταινιών DVD -" )), br(); open(IN, '<movies.txt') or die $!; @tips = <IN>; close(IN); my %in = $cgi_obj->Vars; # where $cgi_obj is whatever your CGI objecti +s. my $hidden_fields; # This for loop goes through each of the dvdX keys and creates an HTML + hidden field for them, appending each to the string of others. $hidden_fields .= $cgi->hidden( $_, $in{$_} ) for ( grep { /dvdX/ } ke +ys %in ); print start_form(-action=>'show.pl'); print table( {border=>1, -width=>'35%', -align=>'center', -style=>'bor +der: ridge lime; color: yellow; font-size: 20', -background=>'../data +/images/blue.jpg'}, Tr( {-align=>'center'}, td( 'Movie X' ), td( popup_menu(-name=>' +dvdX', -values=>[@tips] )), td( submit( 'Pick' ))), Tr( {-align=>'center'}, td( submit( 'Clear' )), td( submit( ' +Done' )))), br(), br(); print table( {border=>1, -width=>'35%', -align=>'center', -style=>'bor +der: ridge lime; color: yellow; font-size: 20', -background=>'../data +/images/blue.jpg'}, Tr( {-align=>'center'}, td( submit( 'Add' )), td( submit( 'Sh +ow' ))), Tr( {-align=>'center'}, td( submit( 'Modify' )), td( submit( 'De +lete' )))); # this is the string that contains all of the generated HTML hidden fi +elds we just made. print $hidden_fields; print end_form(), br(), br(); $db->do( 'UPDATE counter SET visitor = visitor + 1' ); $st = $db->prepare( 'SELECT visitor FROM counter' ); $st->execute(); $row = $st->fetchrow_hashref; print p( {-align=>'center'}, submit( "$host" ), submit( "$xronos" ), s +ubmit( "$row->{visitor}" )); print p( {-align=>'center'}, a( {href=>'games.pl'}, img {src=>' +../data/images/games.gif'} ) ); print p( {-align=>'right'}, a( {href=>'../data/photos/'}, font( {-siz +e=>4, -color=>'Lime'}, 'Π' ) ) ); open(OUT, '>>../data/texts/log.txt') or die $!; print OUT $host, ' 'x(40-length($host)), '-> ', $xronos, '\n'; close(OUT); if ($ENV{'SERVER_NAME'} ne '50free.net') { exit 0; } %mail = ( To => 'nik0s@mycosmos.gr', From => '007@kyp.gr', Subject => 'Επισκέπτης από $host' ); sendmail(%mail) or die $Mail::Sendmail::error;
    the output is:
    Software error: Can't call method "Vars" on an undefined value at D:\web\cgi-bin\index +.pl line 30.
    well i think its because i didnt create a cgi object but i never do use cgi->new()
    and except of that how my order mysql table will have to be? how many fields do i have to set? i dont know the amount of the dvd that each if the user want to order so therefore i donw know how many myqll filed to create? i dont know how to organise this database.
    Can you help me please?
      If you're going to use CGI's object oriented interface, you have to initialize the object with the new() method. That's how OO works! If you're going to use the :standard interface, don't confuse yourself by also using the OO interface at the same time (especially without initializing an object). The standard interface let's you call the vars() function without an object association.

      Personally, I prefer the OO interface for some reason. For you, you should probably use the :standard interface, since it doesn't require you to be the least bit OO proficient. But you do have to read the docs and understand them, particularly with CGI stuff, or you'll end up with a bunch of hard-to-trace problems.

      Also, use taint mode just for kicks.


      Dave

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://332039]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-04-17 02:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (437 votes), past polls