Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts

    How to transfer variables between different htmls

    I downloaded the code from bw.org/using-perl-cgi. It could transfer Efromname, Efromemail, Esubject, and Emessage successfully to the next html. I am trying to add another parameter - Etitle. Strangly enough, it never worked.

    Anyone could give me a clue?

    Thank you in advance.


    Code:
    # ----------------------------------- Load the first page ----------------------------------------
    sub firstpage
    {
    
    my $referer = $qv->{Referer} || $ENV{HTTP_REFERER} || '(none)';
    
    ### Load the html from the config file: 
    
    if(my $firstpage = $g->{CV}{htmlfirst}) {
    
    
      $p->var('Efromname',  $q->escapeHTML($qv->{Efromname}))  if $qv->{Efromname};
      $p->var('Efromemail', $q->escapeHTML($qv->{Efromemail})) if $qv->{Efromemail};
      $p->var('Esubject',   $q->escapeHTML($qv->{Esubject}))   if $qv->{Esubject};
      $p->var('Emessage',   $q->escapeHTML($qv->{Emessage}))   if $qv->{Emessage};
    
      $p->var('Etitle',     $q->escapeHTML($qv->{Etitle}))     if $qv->{Etitle};
    
      $p->var('HIDDENS', hiddens( { Referer => $referer, cmd => 'confirm' } ));
    
      send_header();
    
      $p->pf($firstpage);
    
      }
    
    else { 
      error "htmlfirst must be defined in $g->{config_file}" 
      }
    
    exit;
    
    }
    
    
    
    # ------- Show up the errors if values are missing and move to the confirmation page ---------
    sub confirm
    {
    
    error_confirm("The email address you entered ($qv->{Efromemail}) is not valid.") 
      unless bwEmail::validate_email($qv->{Efromemail});
    
    error_confirm("You must enter your name.") unless $qv->{Efromname} =~ /\S/;
    error_confirm("You must supply a subject for your message.") unless $qv->{Esubject} =~ /\S/;
    error_confirm("The message is empty. Please enter your message.") unless $qv->{Emessage} =~ /\S/;
    
    error_confirm("The title is required.") unless $qv->{Etitle} =~ /\S/;
    
    firstpage() if error_confirm();
    
    ###### If everything is good, continue to the confirmation page: 
    
    if(my $confpage = $g->{CV}{htmlconfirm}) {
    
      # wrap Efromname in quotes, if necessary
      $qv->{qEfromname} = ($qv->{Efromname} =~ /"/) ? $qv->{Efromname} : q|"| . $qv->{Efromname} . q|"| 
        if $qv->{Efromname};
    
      $p->var('Efromname',  $q->escapeHTML($qv->{qEfromname})) if $qv->{Efromname};
      $p->var('Efromemail', $q->escapeHTML($qv->{Efromemail})) if $qv->{Efromemail};
      $p->var('Esubject',   $q->escapeHTML($qv->{Esubject}))   if $qv->{Esubject};
      $p->var('Emessage',   $q->escapeHTML($qv->{Emessage}))   if $qv->{Emessage};
    
      $p->var('Etitle',     $q->escapeHTML($qv->{Etitle}))     if $qv->{Etitle};
    
      $p->var('HIDDENS', hiddens( { 
        Efromname   => $qv->{Efromname}, 
        Efromemail  => $qv->{Efromemail}, 
        Esubject    => $qv->{Esubject}, 
        Emessage    => $qv->{Emessage},
    
        Etitle      => $qv->{Etitle},
    
        Referer     => $qv->{Referer}
    
        } ));
    
      send_header();
    
      $p->pf($confpage);
    
      }
    
    else { 
    
      error "htmlconfirm must be defined in $g->{config_file}" 
    
      }
    
    exit;
    }
    Last edited by camaross; 03-31-2011 at 01:18 AM.

  • #2
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts
    Please help me, folks.

  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by camaross View Post
    Please help me, folks.
    this is bw-contact.tgz ?

    best regards

  • #4
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,877
    Thanks
    2
    Thanked 164 Times in 159 Posts
    Use the Storable module

  • Users who have thanked FishMonger for this post:

    camaross (03-31-2011)

  • #5
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts
    Yes, it is. Are you familiar with it?

    Thanks.


    Quote Originally Posted by oesxyl View Post
    this is bw-contact.tgz ?

    best regards

  • #6
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts
    Thank you FishMonger.

    This is a great option to achieve that.

    Quote Originally Posted by FishMonger View Post

  • #7
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by camaross View Post
    Yes, it is. Are you familiar with it?

    Thanks.
    no, but i find it based on your post, i will try to look to see how it work.

    best regards

  • Users who have thanked oesxyl for this post:

    camaross (03-31-2011)

  • #8
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts
    Thank you very much.

    Quote Originally Posted by oesxyl View Post
    no, but i find it based on your post, i will try to look to see how it work.

    best regards

  • #9
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by camaross View Post
    I downloaded the code from bw.org/using-perl-cgi. It could transfer Efromname, Efromemail, Esubject, and Emessage successfully to the next html. I am trying to add another parameter - Etitle. Strangly enough, it never worked.

    Anyone could give me a clue?

    Thank you in advance.


    Code:
    # ----------------------------------- Load the first page ----------------------------------------
    sub firstpage
    {
    
    my $referer = $qv->{Referer} || $ENV{HTTP_REFERER} || '(none)';
    
    ### Load the html from the config file: 
    
    if(my $firstpage = $g->{CV}{htmlfirst}) {
    
    
      $p->var('Efromname',  $q->escapeHTML($qv->{Efromname}))  if $qv->{Efromname};
      $p->var('Efromemail', $q->escapeHTML($qv->{Efromemail})) if $qv->{Efromemail};
      $p->var('Esubject',   $q->escapeHTML($qv->{Esubject}))   if $qv->{Esubject};
      $p->var('Emessage',   $q->escapeHTML($qv->{Emessage}))   if $qv->{Emessage};
    
      $p->var('Etitle',     $q->escapeHTML($qv->{Etitle}))     if $qv->{Etitle};
    
      $p->var('HIDDENS', hiddens( { Referer => $referer, cmd => 'confirm' } ));
    
      send_header();
    
      $p->pf($firstpage);
    
      }
    
    else { 
      error "htmlfirst must be defined in $g->{config_file}" 
      }
    
    exit;
    
    }
    
    
    
    # ------- Show up the errors if values are missing and move to the confirmation page ---------
    sub confirm
    {
    
    error_confirm("The email address you entered ($qv->{Efromemail}) is not valid.") 
      unless bwEmail::validate_email($qv->{Efromemail});
    
    error_confirm("You must enter your name.") unless $qv->{Efromname} =~ /\S/;
    error_confirm("You must supply a subject for your message.") unless $qv->{Esubject} =~ /\S/;
    error_confirm("The message is empty. Please enter your message.") unless $qv->{Emessage} =~ /\S/;
    
    error_confirm("The title is required.") unless $qv->{Etitle} =~ /\S/;
    
    firstpage() if error_confirm();
    
    ###### If everything is good, continue to the confirmation page: 
    
    if(my $confpage = $g->{CV}{htmlconfirm}) {
    
      # wrap Efromname in quotes, if necessary
      $qv->{qEfromname} = ($qv->{Efromname} =~ /"/) ? $qv->{Efromname} : q|"| . $qv->{Efromname} . q|"| 
        if $qv->{Efromname};
    
      $p->var('Efromname',  $q->escapeHTML($qv->{qEfromname})) if $qv->{Efromname};
      $p->var('Efromemail', $q->escapeHTML($qv->{Efromemail})) if $qv->{Efromemail};
      $p->var('Esubject',   $q->escapeHTML($qv->{Esubject}))   if $qv->{Esubject};
      $p->var('Emessage',   $q->escapeHTML($qv->{Emessage}))   if $qv->{Emessage};
    
      $p->var('Etitle',     $q->escapeHTML($qv->{Etitle}))     if $qv->{Etitle};
    
      $p->var('HIDDENS', hiddens( { 
        Efromname   => $qv->{Efromname}, 
        Efromemail  => $qv->{Efromemail}, 
        Esubject    => $qv->{Esubject}, 
        Emessage    => $qv->{Emessage},
    
        Etitle      => $qv->{Etitle},
    
        Referer     => $qv->{Referer}
    
        } ));
    
      send_header();
    
      $p->pf($confpage);
    
      }
    
    else { 
    
      error "htmlconfirm must be defined in $g->{config_file}" 
    
      }
    
    exit;
    }
    the sub you try to change only pass and filter what it get when the form from html/first.html is submited so you need to add a input text element in the file html/first.html for title:
    Code:
    <p>Title
    <br><input type=text name=Etitle value="$Etitle$" size=45 maxsize=60 class=sans>
    or a textarea:
    Code:
    <p>Title
    <br><textarea name=Etitle wrap=hard rows=10 cols=45 class=sans>$Etitle$</textarea>
    ogly markup, i never understand why some people mess html/css when they write perl or php code.

    best regards

  • Users who have thanked oesxyl for this post:

    camaross (04-01-2011)

  • #10
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts
    Hi Man,

    Thank you so much for the reply. I surely did that. Below is the code that was in my first.html.

    Title: <br />
    <input type="text" name=Etitle value="$Etitle$" size="100" maxlength="300"/>

    I am just so surprised, because I did everything identical to the other parameters, but the program will only carry the 4 intrinsic parameters.

    Would you mind to test it for me?


    Quote Originally Posted by oesxyl View Post
    the sub you try to change only pass and filter what it get when the form from html/first.html is submited so you need to add a input text element in the file html/first.html for title:
    Code:
    <p>Title
    <br><input type=text name=Etitle value="$Etitle$" size=45 maxsize=60 class=sans>
    or a textarea:
    Code:
    <p>Title
    <br><textarea name=Etitle wrap=hard rows=10 cols=45 class=sans>$Etitle$</textarea>
    ogly markup, i never understand why some people mess html/css when they write perl or php code.

    best regards

  • #11
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by camaross View Post
    Hi Man,

    Thank you so much for the reply. I surely did that. Below is the code that was in my first.html.

    Title: <br />
    <input type="text" name=Etitle value="$Etitle$" size="100" maxlength="300"/>

    I am just so surprised, because I did everything identical to the other parameters, but the program will only carry the 4 intrinsic parameters.
    oops, i missed something. look in bwEmail.pm, seems that you need to add a sub title for validation and some code in the sub init to pass arguments.

    Would you mind to test it for me?
    i could but this could take a long time.

    best regards

  • Users who have thanked oesxyl for this post:

    camaross (04-01-2011)

  • #12
    Regular Coder
    Join Date
    Jan 2011
    Posts
    136
    Thanks
    101
    Thanked 0 Times in 0 Posts
    Hello Oesxyl,

    Thank you so much for the hint. I will try to figure this out and let you know how it works.

    Cheers.


    Quote Originally Posted by oesxyl View Post
    oops, i missed something. look in bwEmail.pm, seems that you need to add a sub title for validation and some code in the sub init to pass arguments.


    i could but this could take a long time.

    best regards


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •