如何在错误的同一个html页面上显示表单输出错误在标题之前输出脚本:inputcgi.cgi

时间:2018-01-18 17:20:28

标签: perl cgi

我收到错误:服务器遇到内部错误,无法完成您的请求。错误消息:标题前输出的脚本结束:inputcgi.cgi

请告诉我这可能是什么原因?我试过添加和删除一些行,但没有任何帮助...... 除了这些之外,Cgi文件正确运行..

    #!"c:\xampp\perl\bin\perl.exe"


    use strict;
    use warnings;
    use CGI qw(:all); 

    my $cgi= new CGI;
    my $this_url=$cgi->url();
    my $cr=$cgi->param("cr");
    print $cgi->header();

    print"Content-type:text/html\n\n";

    print << EndofHTML;

    <html>
        <head><link rel="stylesheet" type="text/css" href="style.css">
        <link href="CalendarControl.css"
          rel="stylesheet" type="text/css">
        <script src="CalendarControl.js"
            language="javascript"></script><script src="inputvalidation.js"></script> </head>
        <title>Baseline Automation-Inputs </title>

        <body>
        <font face = "Calibri">
            <div class="divtop"><img src="logo.jpg" </div>
            <div class="head"><h2><font color = "white"><b>TI Patch Request </b></font><h2></div>



        &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                If you have already submitted a request, Click on this button. <a href="google.com" target="_blank">Track Application status </a></td><br><br><br>
            <form name="input" method="POST" action="$this_url">
            &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<i> Fields marked with asterisk <font color="red">*</font>  are compulsory</i>
            <div class="divtable">
            <table cellpadding="3" cellspacing="5">
            <tr>
                <td></td>
                <td>Operating System<font color = red>*</font></td>
                <td><input type="radio" name="ostype" id="windows" onclick="checkno()" >Windows</td>
                <td><input type="radio" name="ostype" id="linux" onclick="checkyes()">Linux</td>
                <td><font color="red"><span id="enteros"></font></span></td>
            </tr>
            <tr>
            </tr>
            <tr>
                <td></td>
                <td>Patch Date and Time<font color = red>*</font></td>
                <td><input name="todays_date"
                        onfocus="showCalendarControl(this);"
                        type="text" style="width:100px;"></td>
    </tr>
            <tr>
                <td></td>
                <td>Server Name <font color = red>*</font></td>
                <td><span title="Press the 'ctrl' key to select multiple servers"><select name="serverlist" id="slist" size="4" multiple>
                        <option value="" disabled selected>Select servers</option>
                        <option>Server 1</option>
                        <option>Server 2</option>
                        <option>Server 3</option>
                        <option>Server 4</option>
                        <option>Server 5</option>
                    </select></span>
                </td>
                <td><font color="red"><span id="enterlist"></font></span></td>
            </tr>
            <tr>
            </tr>

            <tr>
                <td></td>
                <td>Frequency<font color = red>*</font></td>
                <td><input type="radio" name="frequency" id="biannual" onclick="checkcondition()">Biannual</td>
                <td rowspan><input type="radio" name= "frequency" id="monthly" onclick="checkcondition()">Monthly</td>
                <td><font color="red"><span id="enterfreq"></font></span></td>
            </tr>
            <tr>
            </tr>
            <tr>
                <td></td>
                <td>Snapshot Required?<font color = red>*</font></td>
                <td><input type="radio" name="snap" id="yes">Yes</td>
                <td><input type="radio" name="snap" id="no">No</td> 


            </tr>

        <tr>
            </tr>
            <tr>
                <td></td>
                <td>Baseline Update duration<font color = red>*</font></td>
                <td> <input type="radio" name="update" id="one">1 hour</td>
                <td> <input type="radio" name="update" id="two">2 hours</td>
                <td>  <input type="radio" name="update" id="four">4 hours</td>
                <td><font color="red"><span id="enterhour"></font></span></td>
            </tr>
            <tr>
            </tr>
            <tr>
                <td></td>
                <td>Change Request </td>
                <td><input type="text" name="cr" id="cr" maxlength="6" style="width:100px;"></td>
            </tr>

            <tr>
            </tr>
            <tr>
            <td></td>

                <td>Description</td>
                <td colspan="5"> <textarea rows="5" cols="40" placeholder="Enter any comments or queries" align="center"></textarea></td>
            </tr>

             <tr>
            </tr>
            <tr>
                <td></td>
                <td style="word-wrap: break-word;">E-mail (in case you want to    <br> receive notifications)</td>
                <td><input type ="text" name="email" style="width:150px;" onfocus=" " onBlur="ValidateEmail()"> </td>
                <td><font color="red"><span id="invalidemail"></font></span></td>
            </tr>

            </table></div>
            <br> <br> 



                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp

                <input type="button" name="prev" id="prev" value="<<Prev"> 
                <input type="button" name="save" id="save" value="Save" onClick="blank()">
                <input type="button" name="next" id="next" value="Next>>">

            <br>
            <br><br>
            <div class="head"><h2><font color = "white"><b>Selected Request</b></font><h2></div><br> <br> 
            &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp&nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
                &nbsp &nbsp &nbsp &nbsp &nbsp
            <input type = "submit" value ="Submit Request" name="submit">


            </form></font>
            <p>The cr you entered was '$cr'</p> 
        </body>
        </html> 
        EndofHTML
        #So this was the code.

2 个答案:

答案 0 :(得分:3)

如果搜索perl cgi internal error,您会看到对于CGI脚本,通常需要查看错误日志。这将显示发生的实际错误。

在这种情况下,您在所谓的here-document中有错误。在perldoc perlop中阅读相关内容,查找<<EOF

   print <<EOF;
The price is $Price.
EOF
   print << "EOF"; # same as above
The price is $Price.
EOF

请注意,here-doc的标签EOF必须直接在<<之后。如果明确使用带引号的标签,则只能使用空格。

在文档的末尾,标记必须位于行的开头。

答案 1 :(得分:1)

在另一个答案中,您可以解释代码有什么问题。这是一个更普遍的情况。

作为一般规则,在调试CGI脚本时使用库CGI::Carp(请参阅here)始终是个好主意。它会将任何错误发送到浏览器屏幕,而不是将它们放入错误日志中。

这适用于使用croakconfesscarpwarndie报告的错误。最后两个将来自Perl指令的使用或来自Perl本身的错误;其他人来自使用库Carp,这是大多数CPAN库用来向任何调用脚本报告问题的。

因此,您将use CGI::Carp;置于use CGI下并享受。如果您只想抓住die,则可以使用use CGI::Carp qw(fatalsToBrowser);

调试完脚本后,请记得删除此库的使用,因为它为潜在的攻击者提供了太多信息。