CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Perl and Html

 



kate212
New User

Aug 31, 2013, 9:41 PM

Post #1 of 2 (498 views)
Perl and Html Can't Post

Hello there,

Please can anyone provide me with a sample on how to call a perl file to execute from a html button.

This what I tried:


<html>


<form action=name.pl method=post>
Please click here:


<input type=submit value="Press">
</form>

</body>
</html>

Thanks !!


Zhris
User

Sep 2, 2013, 8:21 AM

Post #2 of 2 (478 views)
Re: [kate212] Perl and Html [In reply to] Can't Post

Hi,

The following is a basic CGI script with embedded HTML. I have highlighted key elements in red:


Code
#!/usr/bin/perl 
use strict;
use warnings;
use CGI;

# create new CGI object.
my $cgi = CGI->new( );

# assign value of mybutton "Press" to variable $mybutton.
my $mybutton = $cgi->param('mybutton');

# test if button has been pressed / assign a response message to variable $mybuttonresponse.
my $mybuttonresponse = ( $mybutton ) ? 'button pressed' : 'button not pressed' ;

# print appropriate content type.
print $cgi->header( );

# print HTML.
print <<"HTMLcode";
<html>
<head>

</head>
<body>
<p>$mybuttonresponse</p>
<form action="name.pl" method="post">
Please click here: <input type="submit" name="mybutton" value="Press">
</form>
</body>
</html>
HTMLcode

exit;


Chris


(This post was edited by Zhris on Sep 2, 2013, 8:21 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives