Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

why this simple cgi script returns error ? !

by adam_blackice (Acolyte)
on Apr 04, 2007 at 20:50 UTC ( [id://608369]=perlquestion: print w/replies, xml ) Need Help??

adam_blackice has asked for the wisdom of the Perl Monks concerning the following question:

hello all> i wrote asimple cgi scripts that take inputs from user and preview it in the second page by a cgi script so here is the first one that makes the form .
#!/usr/bin/perl -w use strict; print "Content-type: text/html\n\n"; print "<html><head><title>Our First HTML Perl form</title></head>"; print "<body>"; print"<form method='post' action='action1.pl'>"; print"name: <input type='text' name='name' size='25'><br>"; print"email: <input type='text' name='email' size='25'><br>"; print"<input type='submit' value='Submit'>"; print"</form>"; print"</body></html>";
and th action script is
#!/usr/bin/perl use cgi; $cgi=new CGI; print $cgi->header(); print $cgi->start_html("Action page"); print $cgi->param('name'), <br>; print $cgi->param('email'); print $cgi->end_html();
so when i run this from the browser first it shows me the
form and every thing is ok .........
but after i click submit i got this
<<internal server error>>
and form apache log files i found that
#!/usr/bin/perl use cgi; $cgi=new CGI; print $cgi->header(); print $cgi->start_html("Action page"); print $cgi->param('name'), <br>; print $cgi->param('email'); print $cgi->end_html();

Replies are listed 'Best First'.
Re: why this simple cgi script returns error ? !
by ikegami (Patriarch) on Apr 04, 2007 at 21:00 UTC

    You made two errors posting your question:

    • You posted your node to Perl Monks Discussion. (I moved it to Seekers of Perl Wisdom.) The former is for questions and discussions about this site. The latter is help with Perl.

    • I think you meant to post the error message from the log file at the end, but you reposted an earlier snippet.

    You made two errors in your code:

    • The first is use cgi;. That should be use CGI;. What you have will *appear* to work in case-insensitive systems like Windows, and fail completely on case-sensitive systems like unix.

    • The second is <br>. That means "read a line from the file handle br." You want

      print $cgi->param('name'), $cgi->br;
      or
      print $cgi->param('name'), '<br>';

    Update: Typo fixes

      first iam sorry for my mistakes and i not going to make the same mistakes .....\
      so the problem was in the
      and i made it and every thing is fine now
      thanx for all :)
        When posting to this site, you can escape html with <c></c> tags, as in
        problem was in the <c><br /></c> and
        or by using &lt; as in
        problem was in the &lt;br /> and
        Writeup Formatting Tips may come in handy. Cheers.
Re: why this simple cgi script returns error ? !
by Joost (Canon) on Apr 04, 2007 at 20:55 UTC
Re: why this simple cgi script returns error ? !
by Trizor (Pilgrim) on Apr 04, 2007 at 20:56 UTC
    <br> needs to be in quotes, otherwise perl assumes you're trying to read the contents of the br filehandle.
Re: why this simple cgi script returns error ? !
by robot_tourist (Hermit) on Apr 05, 2007 at 11:47 UTC

    You could just use a normal html file for the first script since it doesn't actually have to process anything.

    Don't forget the Taint switch.

    Obiligatory link to Ovid's CGI course.

    How can you feel when you're made of steel? I am made of steel. I am the Robot Tourist.
    Robot Tourist, by Ten Benson

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://608369]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-03-29 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found