Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Send HTML to the server

by vit (Friar)
on Sep 11, 2011 at 23:46 UTC ( [id://925390]=note: print w/replies, xml ) Need Help??


in reply to Re: Send HTML to the server
in thread Send HTML to the server

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.

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

    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.

      This is great. One question though, might be stupid. How did you run the script? I have showme.html and showme.pl in the same directory. The first one pops up the browser, then when I submit what should happen?
      Please do me a favor and explain this.

        You did upload both files to a webserver, didn't you? And that webserver is configured to handle CGI scripts, isn't it? And you've made sure you've set the permissions for showme.pl correct, haven't you?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2024-04-24 09:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found