Development Articles
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherDevelopment Articles

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 26th, 2000, 07:50 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
typo!

clearly there's a typo in here:
%myhero = ("fname" =< "Donald", "lname" => "Duck");

should read
%myhero = ("fname" => "Donald", "lname" => "Duck");

Reply With Quote
  #2  
Old September 29th, 2000, 05:46 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Help!

Please help!!!
<br>
<br>
I saved the form from Perl 101 part 7 into a html file "getname.html" and here is the content:
<br>
--------------------------------------
<br>
<html>
<br>
<head>
<br>
<basefont face=Arial>
<br>
</head>
<br>
<body>
<br>
<form action=http://host_ip#/cgi-bin/readform.cgi method=GET>
<br>
Enter your first name: <input type=text length=20 name=name><br>
<br>
<input type=submit value=Submit>
<br>
</form>
<br>
</body>
<br>
</html>
<br>
----------------------------------
<br>
and then I saved the CGI script that receives and processes the data. readform.cgi at the same location and here is the content of this file:
<br>
------------------------------------
<br>
#!/usr/bin/perl
<br>
<br>
# readform.cgi
<br>
# reads form data and generates a page
<br>
<br>
# for GET data
<br>
if ($ENV{'REQUEST_METHOD'} eq "GET")
<br>
{
<br>
$yourname=$ENV{'QUERY_STRING'};
<br>
}
<br>
# for POST data
<br>
else
<br>
{
<br>
$yourname = <STDIN>;
<br>
}
<br>
<br>
# Remove spaces if any
<br>
$yourname =~ s/\+/ /g;
<br>
<br>
# split form data and store in hash
<br>
%details = split (/=/, $yourname);
<br>
<br>
# generate page
<br>
print "Content-Type: text/html\n\n";
<br>
print "<html><body>";
<br>
<br>
while (($name, $value) = each %details)
<br>
{
<br>
print "Thank you for your submission, $value!\n";
<br>
}
<br>
<br>
print "</body></html>";
<br>
------------------------------------
<br>
<br>
After doing this I pull the from on to a browser and type in the name "ASIF" and press enter and the result is:
<br>
<br>
the URL field shows:
<br>
http://host_ip#/cgi-bin/readform.cgi?name=ASIF
<br>
the body of the browser shows:
<br>
HTTP 500 - Internal server error
<br>
<br>
(of cause some other junk info above and below this error for MS IExplorer)
<br>
<br>
My server is a NT 4.0 web server and I have active perl (stable ver) installed and I know it works coz I can use other pl scripts.
<br>
<br>
Can someone help???
<br>
<br>
Thanks a million in advance
<br>
Asif
<br>
asift@netscape.net
<br>
<br>

Reply With Quote
  #3  
Old October 1st, 2000, 03:07 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
use strict;

Your series is very informative.

Do any of the CGI installments include use strict;

Along with -w of course?

Thanks

Reply With Quote
  #4  
Old October 3rd, 2000, 02:32 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: Help!

I found the problem....my web server did not know how to handle filename.CGI file - file association problem is now fixed

Asif

Reply With Quote
  #5  
Old October 5th, 2000, 01:00 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Get and Post

I have had a problem with POST. I think it might not be enabled. How do I check and if so How do I install or enable it.

Reply With Quote
  #6  
Old October 24th, 2000, 11:04 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
cgi

Thank you. Fun fun fun.

Reply With Quote
  #7  
Old November 26th, 2000, 07:11 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
param() ???

Why is it that every single perl form tutorial explains that god awful process for using <STDIN> and translating and substituting the value? Ever heard of the param() function? Its meaningless to even teach anyone this if they can just use param().

Reply With Quote
  #8  
Old January 24th, 2001, 04:42 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: cgi

ditto

Thanks for your assistance. It is fun the first time a new language* is made to work.

* new to me :)

Reply With Quote
  #9  
Old January 26th, 2001, 09:00 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: typo!

Another little one, but quite important I feel in the understanding of a new function:
On page 4,


<!-- Code -->
<p><pre><font color=#008000><xmp># get the names
@year = keys(%director);</xmp></font></pre><p>
<!-- Code -->


should be


<!-- Code -->
<p><pre><font color=#008000><xmp># get the years
@year = keys(%director);</xmp></font></pre><p>
<!-- Code -->


Reply With Quote
  #10  
Old April 20th, 2001, 04:49 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: Get and Post

I think I have the same problem. Let me know if you fixed it

Reply With Quote
  #11  
Old April 20th, 2001, 08:56 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: Get and Post

man i posted that nearly a year ago.
I dont even have apache installed any more.
I'm not sure of what the problem turned out to be but the script sorta worked. The user could input some text and it got mailed to me but it didn't return to the page it was spose to after.

Joe

Reply With Quote
  #12  
Old April 21st, 2001, 01:26 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: Get and Post

Thanks for replying anyhow. I'll figure it out.. I didnt look at the date (obviously). I have the same problem, It mails me the form results, but it doesnt redirect afterwards. It isnt mission critical anyway. Its my home pc.

do you use a different web server?

Thanks,
Paul Adams

Reply With Quote
  #13  
Old July 26th, 2001, 05:39 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: param() ???

Using CGI.pm is so much better, agreed. Everyone uses CGI.pm, it comes with your Perl distribution. There is no reason not to use it. Why write potentially flawed and insecure code when someone else has already done most of the work for you, better than you could, and more securely than you could, for the past few years?

Reply With Quote
  #14  
Old January 28th, 2002, 06:22 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
  #15  
Old February 22nd, 2002, 03:51 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherDevelopment Articles > Perl 101 (part 7) - CGI Basics


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway