Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy problem with beginner's cgi script for HTML forms

    Hi I am new to Perl.

    I have written following code in HTML for forms -

    <form action="echo1.cgi"">
    <div>Please type some text: <input name="sample" size="20"></div>
    <div><input type="submit"></div>
    </form>



    Corresponding cgi script is -

    #!/usr/bin/perl

    use CGI qw(:standard);
    $data = param('sample') || '<i>(No input)</i>';

    print <<END;
    Content-Type: text/html; charset=iso-8859-1

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <title>Echoing user input</title>
    <h1>Echoing user input</h1>
    <p>You typed: $data</p>
    END


    When I open HTML page from browser and type some input and click on 'Submit' button it gives me output -

    #!/usr/bin/perl

    use CGI qw(:standard);
    $data = param('sample') || '<i>(No input)</i>';

    print <<END;
    Content-Type: text/html; charset=iso-8859-1

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <title>Echoing user input</title>
    <h1>Echoing user input</h1>
    <p>You typed: $data</p>
    END



    So i guess instead of executing the echo1.cgi script , it is just displayed.

    I have set permissions of all files to 755. I am using Fedora OS.

    What can be the problem?

    Please help!!!!

  • #2
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,877
    Thanks
    2
    Thanked 164 Times in 159 Posts
    Is the script in the cgi-bin directory? It doesn't appear to be.

    Move it to the cgi-bin directory and change the form's action attribute to point to that directory.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •