how to make to transmit the parameters of a cgi between these various pages I would like to use para

Discussion in 'Perl Misc' started by john.swilting, Mar 27, 2007.

  1. my cgi functions on several windows.I' would like to be able to recover the
    parameter $image which comes from the form of the gallery photographs of
    the first window towards the second window and the third window.I know
    there is the instruction param, but I do not manage to use it in my cgi
    my code functions well and it compiles without warnings
    #!/usr/bin/perl -w
    use diagnostics;
    use strict;
    use CGI qw:)standard escapeHTML);
    use CGI::Carp qw(fatalsToBrowser);

    my $cgi;
    my $key;
    my %etats;
    my $ecran_actuel;

    $cgi = new CGI;

    %etats = (
    'defaut' =>\&commander,
    'saisie_commande' =>\&saisie_commande,
    'validation_commande' =>\&validation_commande,
    );
    $ecran_actuel = param(".Etat") || "defaut";
    die "Pas d'ecran pour $ecran_actuel" unless $etats{$ecran_actuel};


    ## engendre le document courant
    en_tete_standard();
    while ( my ($nom_ecran,$fonction) = each %etats){
    $fonction->($nom_ecran eq $ecran_actuel);
    }

    pied_de_page_standard();

    ########################################################################
    ## fonctions d en tete , de pied de page ,de menu ################
    ########################################################################

    sub en_tete_standard {
    print header(),
    start_html(-Title => "commande" , -BGCOLOR=>"White");
    print start_form();
    }


    sub pied_de_page_standard{ print end_form(),end_html() }


    sub menu_boutique{
    print p(defaults("vider mon cadie"),
    vers_doc("saisie_commande"));
    }

    sub commander {
    my($actif) = @_;
    return unless $actif;
    my $image = param ('image');
    if ( $image == '') {
    die "error";
    }
    print "<H1>salut !</H1>\n";
    print p("bienvenue dnas notre magasin de peintures !");
    print p("vous avez selectionner la
    peintures ",tt(escapeHTML($image)),"\n");

    menu_boutique();
    return $image;
    }
    sub saisie_commande {
    my $actif = shift;
    ## my($image) = main::commander;
    my @gadgets = qw(Nom Adresse Ville Code_postal Pays Telephone Mail);
    unless ( $actif ) {
    print map { hidden($_) } @gadgets;
    return;
    }
    print p("Tous les champs sont obligatoires sinons votre commande ne sera
    pas valable");
    print p("vous pouvez remplir au choix votre numero de telephone ou votre
    mail pour le suivie de la commande");
    ## print p("image ",tt(escapeHTML($image)));
    print pre ( p ("Nom\&nbsp;: ",textfield("Nom")),
    p ("Adresse\&nbsp;: ",textfield("Adresse")),
    p ("Ville\&nbsp;: ",textfield("Ville")),
    p ("Code Postal\&nbsp;: ",textfield("Code_postal")),
    p ("Pays\&nbsp;: ",textfield("Pays")),
    p ("Telephone\&nbsp;: ",textfield("Teléphone")),
    p ("e-mail\&nbsp;: ",textfield("Mail")));

    print p ( "Selectionner validation_commande pour commander\n",
    "la peintures. autrement selectionner Annulation\n");

    print p ( vers_doc("validation_commande"), vers_doc("Annulation"));
    }

    sub validation_commande {
    my $actif = shift;
    unless ( $actif) {
    return;
    }
    my $numero_commande = time;
    my $nom = param ('Nom');
    my $adresse = param ('Adresse');
    my $ville = param ('Ville');
    my $code_postal = param ('Code_postal');
    my $pays = param ('Pays');
    my $telephone = param ('Teléphone');
    my $mail = param ('Mail');
    print h1("Commander !");
    print p("vous aller recevoir un e-mail avec un numero de commande");
    print p("vous serez prevenue quand le paquet sera posté");
    print p("dans toutes correspondance indiquer votre numero de
    commande",tt(escapeHTML($numero_commande)));
    print p("debug ",tt(escapeHTML($nom)));
    print p("debug ",tt(escapeHTML($adresse)));
    print p("debug ",tt(escapeHTML($ville)));
    print p("debug ",tt(escapeHTML($pays)));
    print p("debug ",tt(escapeHTML($telephone)));
    print p("debug ",tt(escapeHTML($mail)));
    print p(defaults("Retour au debut"));
    }
    sub vers_doc { submit (-NAME => ".Etat", -VALUE => shift) }
    john.swilting, Mar 27, 2007
    #1
    1. Advertising

  2. john.swilting

    -berlin.de Guest

    john.swilting <> wrote in comp.lang.perl.misc:
    >
    > my cgi functions on several windows.I' would like to be able to recover the
    > parameter $image which comes from the form of the gallery photographs of
    > the first window towards the second window and the third window.


    You can use hidden fields to pass parameters from one invocation to
    the next. (In fact, you already seem to do that in another place.)
    So add a hidden field "image" to those forms that don't already have
    it.

    print hidden('image', $image);

    Then "my $image = param( 'image')" will restore the value.

    Anno
    -berlin.de, Mar 27, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex
    Replies:
    0
    Views:
    405
  2. Sergio Alvarez

    Ayuda para java

    Sergio Alvarez, Jan 21, 2006, in forum: Java
    Replies:
    4
    Views:
    2,388
    Mike Schilling
    Jan 22, 2006
  3. VisionSet
    Replies:
    5
    Views:
    338
    Chris Morris
    Sep 20, 2003
  4. mvogel

    apoyo para el tema xml

    mvogel, May 12, 2005, in forum: XML
    Replies:
    0
    Views:
    447
    mvogel
    May 12, 2005
  5. bienwell
    Replies:
    4
    Views:
    736
    Juan T. Llibre
    Oct 19, 2006
Loading...

Share This Page