Once again: CGI help 
Author Message
 Once again: CGI help

Hello all!

Sorry for this long posting. I boiled down my script as far as I
could. But it is still very long!

My Questions:

1. How do I create the $order_date. I am doing something wrong here
2. How do I check, whether the $order_date was changed against the
default: 01/Jan/2009 - 00:00. The $order_date would be later
obligatory (must          => 1; it is commented out)
3. How to pass the form elements to the formmail.pl from :
http://www.*-*-*.com/

Thank you all for your patience.

marek

#! /usr/bin/perl

use strict;
use warnings;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

$CGI::DISABLE_UPLOADS = $CGI::DISABLE_UPLOADS = 1;
$CGI::POST_MAX        = $CGI::POST_MAX        = 4096;

my $color;
my $order_date;
my $warnung;


    {
        type  => "headline",
        name  => "Pickup Time",
        color => "#C0C0C4"
    },
    {
        type => 'popup',
        bez  => 'Day/Month/Year/ - hr:min',

        # must    => 1;
        date_time1 => [
            {
                name  => 'day',
                value => [
                    "01", "02", "03", "04", "05", "06", "07", "08",
                    "09", "10", "11", "12", "13", "14", "15", "16",
                    "17", "18", "19", "20", "21", "22", "23", "24",
                    "25", "26", "27", "28", "29", "30", "31"
                ]
            },
            {
                name  => 'month',
                value => [
                    "Jan", "Feb", "M?r", "Apr", "Mai", "Jun",
                    "Jul", "Aug", "Sep",  "Okt", "Nov", "Dez"
                ]
            },
            {
                name  => 'year',
                value => [ '2009', '2010', '2011', '2012' ]
            }
        ],
        date_time2 => [
            {
                name  => 'hour',
                value => [
                    "01", "02", "03", "04", "05", "06", "07", "08",
                    "09", "10", "11", "12", "13", "14", "15", "16",
                    "17", "18", "19", "20", "21", "22", "23", "24"
                ]
            },
            {
                name  => 'minutes',
                value => [
                    "05", "10", "15", "20", "25", "30", "35", "45",
"55", "55"
                ]
            }
        ]
    },
    {
        type  => "headline",
        name  => "Pickup Place/Destination",
        color => "#FFFFFF"
    },
    {
        type => "text",
        name => "from_where",
        bez  => "Von:",
        size => 36,
        must => 1
    },
    {
        type => "text",
        name => "whereto",
        bez  => "Whereto:",
        size => 36,
        must => 1
    }
);

my $table_start = <<"EOF";
        <table width="1006" align="center" border="0" cellspacing="0"
cellpadding="0">
                <tr>
                        <td align="left" valign="middle" bgcolor="#0E1E3F" rowspan="37">
                                <img src=" http://www.*-*-*.com/ ;
alt="" width="3" height="3" />
                        </td>
                        <td align="left" valign="middle" bgcolor="#0E1E3F" colspan="2">
                                <img src=" http://www.*-*-*.com/ ;
alt="" width="3" height="3" />
                        </td>
                        <td align="left" valign="middle" bgcolor="#0E1E3F" rowspan="37">
                                <img src=" http://www.*-*-*.com/ ;
alt="" width="3" height="3" />
                        </td>
                </tr>
                <tr>
                        <td width="500">
                                <img src=" http://www.*-*-*.com/
grandtaxi_logo_01.jpg" alt="Logo Grand Taxi" width="500" height="100" /
                        </td>
                        <td width="500" bgcolor="#FFFFFF">
                                &nbsp;
                        </td>
                </tr>
                <tr>
                        <td bgcolor="#EDD4C3" colspan="2">
                                <img src=" http://www.*-*-*.com/ ;
alt="" width="3" height="3" />
                        </td>
                </tr>
                <tr bgcolor="#FFFFFF">
                        <td valign="middle" colspan="2" align="center">
EOF

my $table_start2 = <<"EOF";
                        </td>
                </tr>
                <tr>
                        <td bgcolor="#EDD4C3" colspan="2">
                                <img src=" http://www.*-*-*.com/ ;
alt="" width="3" height="3" />
                        </td>
                </tr>
EOF

my $table_end = <<"EOF";
                <tr>
                        <td bgcolor="#EDD4C3" colspan="2" height="3">
                                <img src=" http://www.*-*-*.com/ ;
alt="" width="3" height="3" />
                        </td>
                </tr>
                <tr>
                        <td bgcolor="#0E1E3F" colspan="2" height="3">
                                <img src=" http://www.*-*-*.com/ ;
alt="" width="3" height="3" />
                        </td>
                </tr>
        </table>
EOF

print header ( -charset => 'utf-8' ),
  start_html(
    {
        -dtd   => '-//W3C//DTD XHTML 1.0 Transitional//EN',
        -title => 'FormTest',
        -style =>
          { 'src' => ' http://www.*-*-*.com/
style_giessl.css' }
    }
  );

# Dispatch to proper action based on user selection

my $action = lc( param("action") );
if ( $action eq "" ) {

Quote:
}

elsif ( $action eq "send" ) {

Quote:
}

print end_html();

exit(0);

#
----------------------------------------------------------------------
# Eingabe-Formular anzeigen

sub show_form {
    my $element_liste_ref = shift;

    print start_form ( -action => url() );
    print $table_start;
    if ( defined $order_date ) {
        print h1 ("Ihre Bestellung fr den $order_date");
    }
    print p (
        { -class => "vorwort" },
"Bitte geben sie die Registrierungs-Daten ein, und dr&uuml;cken Sie
dann den <strong>Absenden</strong>-Knopf. <br />Felder mit einem
Sternchen* sind Pflichtfelder!"

      );
    if ( defined $warnung ) {
        print p ( { -class => "warnung" }, $warnung )
          ; # This is the warning, if something is not filled out in
the form ...
    }
    print $table_start2;


        my $type = $f->{type};
        my $bez  = $f->{bez};
        $bez .= "*" if $f->{must};
        my $class;
        if ( $f->{class} ) {
            $class = $f->{class};
        }
        else {
            $class = "no_alert";
        }
        if ( $type eq "headline" ) {
            $color = $f->{color};
            my $headline = $f->{name};
            push(

                Tr(
                    { -bgcolor => "$color" },
                    td( { -colspan => '2' }, h1($headline) )
                )
            );
        }

        elsif ( $type eq 'popup' and $f->{bez} =~ /Month/ ) {




                  popup_menu(
                    -name  => $_->{name},
                    -value => $_->{value}
                  );
            }


                  popup_menu(
                    -name  => $_->{name},
                    -value => $_->{value}
                  );
            }

              Tr(
                { -bgcolor => "$color" },
                td( p( { -class => $class }, $bez ) ),
                td(
                    { -align => 'left' },

                )
              );
        }
        if ( $type eq "text" ) {
            push(

                Tr(
                    { -bgcolor => "$color" },
                    td( p( { -class => $class }, $bez ) ),
                    td(
                        textfield(
                            -name => $f->{name},
                            -size => $f->{size}
                        )
                    )
                )
            );
        }
    }


        print $zeile;
    }
    print qq(<tr><td bgcolor="#EDD4C3" colspan="2">);
    print p( { -align => 'right' },
        defaults( -value => "Alles L&ouml;schen" ),
        submit( -name => "action", -value => "Send" ) );
    print "</td></tr>";
    print $table_end;
    print endform;
    print "<p>&nbsp;</p>";

Quote:
}

sub formular_check {
    my $element_liste_ref = shift;


        my $value = param( $f->{name} );
        $value = "" unless defined($value);
        $value =~ s/^\s+//;
        $value =~ s/\s+$//;
        $f->{value} = $value;

        if ( $f->{bez} =~ /Monat/ ) {



                my $value = param( $f->{name} );

working!
            }

                my $value = param( $f->{name} );

working!
            }
            $order_date =

        }

        if ( $value eq "" && $f->{must} ) {
            my $problem = $f->{bez};
            $problem =~ s/:\s*$//;
            $problem =~ s/^\s+//;

            $f->{class} = 'red_alert'
              ;    # "red_alert" from Stylesheet
        }
    }

        $warnung =
"Es fehlt noch etwas. Bitte f&uuml;llen Sie die rot markierten Felder
aus: ";

        $warnung .= "!";
        show_form($element_liste_ref);

        # neu anzeigen
        return;
    }
    else {
        feedback($element_liste_ref);

        # send_order($element_liste_ref);

    }

Quote:
}

sub feedback {

    my $element_liste_ref = shift;

    print $table_start;
    if ( defined $order_date ) {
        print h1 ("Your order for $order_date");
    }



        my $class = "no_alert";
        my $bez   = $f->{bez};
        my $size  = 36;
        next if $f->{value} eq "";
        my $value = param( $f->{name} );
        $value = "" unless defined($value);
        $value =~ s/^\s+//;
        $value =~ s/\s+$//;
...

read more »



Sat, 24 Mar 2012 08:05:26 GMT  
 Once again: CGI help
In article

Quote:

> Hello all!

> Sorry for this long posting. I boiled down my script as far as I
> could. But it is still very long!

It is too long. If you expect to get help with your problem(s), you
need to write a shorter program that exhibits the problem you are
having.

Quote:

> My Questions:

> 1. How do I create the $order_date. I am doing something wrong here

What is $order_date supposed to contain?

Quote:
> 2. How do I check, whether the $order_date was changed against the
> default: 01/Jan/2009 - 00:00. The $order_date would be later
> obligatory (must    => 1; it is commented out)

You can compare strings with the eq and ne operators:

  if( $order_date ne $default_date ) {
    # $order_date has been changed
  }

Quote:
> 3. How to pass the form elements to the formmail.pl from :
> http://nms-cgi.sourceforge.net/ ???

You would define the query string that formmail expects from an
appropriate web page and call formmail. However, that is probably not
what you want to do. You would be better off combining your script with
formmail. If all you want to do is email some information somewhere,
you don't need all of formmail. Just extract the parts of formmail that
send email (paying attention to the security measures that formmail
uses) and add those to your program. Or use one of the many other ways
to send email from a Perl program.

Quote:

> Thank you all for your patience.

My patience is limited.

--
Jim Gibson



Sat, 24 Mar 2012 20:28:10 GMT  
 Once again: CGI help

Quote:

> My patience is limited.

So why are you answering? I am beginner, and your answers you gave are
not really helpful!

Quote:
> What is $order_date supposed to contain?

For that reason I posted the very long (sorry again!) script:


Quote:
> You can compare strings with the eq and ne operators:

>   if( $order_date ne $default_date ) {
>     # $order_date has been changed
>   }

This I know! Even as a beginner.

Quote:
> you don't need all of formmail. Just extract the parts of formmail that

send email

Not really helpful either. Considering the logic of my script, I have
no place for <form method="post" action="../cgi-bin/FormMail.pl">. How
do I hand over the form elements after sub formular_check to
FormMail.pl ?

There are people jumping on every excuse, to make them smaller to seem
themselves bigger.

marek



Sun, 25 Mar 2012 09:30:26 GMT  
 Once again: CGI help

    M> So why are you answering? I am beginner, and your answers you
    M> gave are not really helpful!

1 - The answers he gave answered your questions clearly and concisely.

2 - He is also helping you to realize that *everyone's* patience here is
limited, and that you would do very well to read the Posting Guidelines
that are posted here frequently and follow them.  

Charlton

--
Charlton Wilbur



Sun, 25 Mar 2012 16:18:25 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Re(Once again): Forcing string to integers...

2. once again print SOCK "Whatever";

3. on again/off again CGI prob...

4. Help Again---Still a easy CGI program

5. Help Again---Still a easy CGI program

6. numbers & strings again (and again and again)

7. cookie pain (no not cgi::cookie again)

8. CGI.pm and perl to C compiler again

9. AGAIN about the CGI program

10. CGI.pm and perl to C compiler again

11. trying it again... please help ;-(

12. Perl & Linux - Help again

 

 
Powered by phpBB® Forum Software