Current location: Hot Scripts Forums » Programming Languages » Perl » PERL/CGI What is bad? Help?????


PERL/CGI What is bad? Help?????

Reply
  #1 (permalink)  
Old 04-14-05, 09:11 AM
angbermu's Avatar
angbermu angbermu is offline
Newbie Coder
 
Join Date: Apr 2005
Location: Cidra, Puerto Rico
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
PERL/CGI What is bad? Help?????

I have problems working with my form in perl. For example in php i use:


<html>
<head></head>
<body>
<h2>Today's Special</h2>
<p>
<form method="get" action="cooking.php">
<select name="day">
<option value="1">Monday/Wednesday
<option value="2">Tuesday/Thursday
<option value="3">Friday/Sunday
<option value="4">Saturday
</select>
<input type="submit" value="Send">
</form>
</body>
</html>

With this script:

<html>
<head></head>
<body>

<?php
// get form selection
$day = $_GET['day'];
// check value and select appropriate item
if ($day == 1) {
$special = 'Chicken in oyster sauce';
}
elseif ($day == 2) {
$special = 'French onion soup';
}
elseif ($day == 3) {
$special = 'Pork chops with mashed potatoes and green salad';
}
else {
$special = 'Fish and chips';
}
?>

<h2>Today's special is:</h2>
<?php echo $special; ?>
</body>
</html>

THis work fine but i need to the same in perl/cgi and i receive errors.
this is the form:
<HTML>
<BODY>
<FORM method="post" action="http://yoursite.com/cgi-bin/testform.cgi">
Name: <INPUT TYPE="text" name="username" size="30">
<BR>
<INPUT TYPE="submit">
</FORM>
</BODY>
</HTML>

this is the cgi:

#!/usr/bin/perl

$uname= $input{'username'};
print "Content-type: text/html\n\n";
print "<HTML><BODY>";
print "Hi $uname, welcome!";
print "</BODY></HTML>";

What i am doing bad? because i receive some error when submit.
Help??????
__________________
angbermu
"Opportunity is never lost just found by someone else"
Reply With Quote
  #2 (permalink)  
Old 04-14-05, 01:55 PM
angbermu's Avatar
angbermu angbermu is offline
Newbie Coder
 
Join Date: Apr 2005
Location: Cidra, Puerto Rico
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
no help for my question?
__________________
angbermu
"Opportunity is never lost just found by someone else"
Reply With Quote
  #3 (permalink)  
Old 04-14-05, 03:28 PM
Chas Chas is offline
Coding Addict
 
Join Date: Oct 2003
Location: California
Posts: 359
Thanks: 0
Thanked 0 Times in 0 Posts
CGI.pm

You need to use CGI.pm to access your parameters:

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

my $q = CGI->new;

my $uname = $q->param('username');

print $q->header;
print "<HTML><BODY>";
print "Hi $uname, welcome!";
print "</BODY></HTML>";
Make sure you read the POD for CGI:

http://search.cpan.org/~lds/CGI.pm/CGI.pm

~Charlie
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is hacking good or bad? jakediddy The Lounge 11 10-14-11 10:30 AM
Perl/CGI & PHP how to's namagodai Perl 1 03-26-05 12:40 AM
Is there a fucntion like include in perl/cgi Tempestshade Perl 3 01-26-05 12:38 AM
perl/cgi newbie. hangman.cgi script adding html-like code on web and other trouble Arowana Perl 12 11-13-03 02:24 PM
Question from a former Perl/CGI programmer, re: ASP.net jackolantern ASP.NET 2 10-03-03 01:59 PM


All times are GMT -5. The time now is 04:03 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.