vit has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
In my Perl/CGI program I need to submit HTML to the server as is from the form in the browser. I guess using a simple
input type="text" ....
is not a right way. So how can I do this?

Replies are listed 'Best First'.
Re: Send HTML to the server
by muba (Priest) on Sep 11, 2011 at 23:15 UTC

    No? What do you think would be wrong with a <input type="text" name="myHTML"> or a <textarea name="myHTML"></textarea>?

      So simple
      <textarea name="myHTML"></textarea>
      should work for ant HTML content without any decoding/encoding and will be transfered to the server just fine preserving all symbols ?
      If this is the case I am all set.

        Sure.

        <!-- showme.htm --> <html> <body> <form method="POST" action="showme.pl"> <textarea name="myHTML"></textarea> <input type="checkbox" name="asHTML">Show as HTML <input type="submit"> </form> </body> </html>
        #!/usr/bin/perl # showme.pl use strict; use warnings; use CGI 'param'; my $html = param('myHTML'); my $ashtml = param('asHTML'); if ($ashtml) { print "Content-Type: text/html\n\n"; print $html; } else { print "Content-Type: text/plain\n\n"; print "The HTML you submitted looks like:\n"; print "*" x 76, "\n"; print $html; print "\n", "*" x 76, "\n"; }

        Given this input in the textarea:

        <html> <head> <title>Show me</title> </head> <body>Hi</body> </html>

        Without checking the box I get this output:

        The HTML you submitted looks like: ********************************************************************** +****** <html> <head> <title>Show me</title> </head> <body>Hi</body> </html> ********************************************************************** +******

        And if I check the box I just get a page saying "Hi", titled "Show me". It really isn't that hard.

Re: Send HTML to the server
by Khen1950fx (Canon) on Sep 11, 2011 at 23:19 UTC
    Maybe something like this, using an email address:

    The form element

    <form_action="cgi-bin/upload.cgi" method="post" enctype="multipart/for +m-data">
    The form field
    <p>Your email address: <input type="text" name="email_address" /></p>
    The submit button
    <p><input type="submit" name="Submit" value="Submit Form" /></p>

      But how does that send html as-is to the server?