Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    typo!


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

    should read
    %myhero = ("fname" => "Donald", "lname" => "Duck");
  2. #2
  3. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    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>
  4. #3
  5. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    use strict;


    Your series is very informative.

    Do any of the CGI installments include use strict;

    Along with -w of course?

    Thanks
  6. #4
  7. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    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
  8. #5
  9. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    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.
  10. #6
  11. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    cgi


    Thank you. Fun fun fun.
  12. #7
  13. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    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().
  14. #8
  15. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Re: cgi


    ditto

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

    * new to me :)
  16. #9
  17. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    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 -->

  18. #10
  19. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    Re: Get and Post


    I think I have the same problem. Let me know if you fixed it
  20. #11
  21. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    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
  22. #12
  23. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    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
  24. #13
  25. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)

    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?
  26. #14
  27. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)
  28. #15
  29. No Profile Picture
    guest
    Guest
    Devshed Newbie (0 - 499 posts)
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo