PHP表单生成500 - 内部服务器错误

时间:2014-10-01 14:00:37

标签: php forms internal-server-error

我有一个已添加到我网站的基本联系表格。表单似乎有效,直到您点击提交,然后您收到如下错误:

500 - 内部服务器错误。 您正在查找的资源存在问题,无法显示。

地址栏中的URL是使其可用的PHP文件。我已检查并重新检查它,确保电子邮件地址和页面名称正确,但我看不出有什么问题。

以下是表单代码:

 <form method="post" id="captcha_form" name="captcha_form" action="mailform.php"><fieldset><ol>
    <li id="ht"><label class="solo" for="htest">Leave this input blank</label>
    <span  class="required">(required)</span>
    <input type="text" class="soloinput" name="htest" id="htest" value="" />

    </li><li><label class="solo" for="email">Email address:</label>
    <span class="required">(required)</span>
    <input type="text" class="soloinput" name="email" id="email" value="" />

    </li><li><label class="solo" for="name">Name:</label><span class="required">(required)</span><input type="text" class="soloinput" name="name" id="name" value="" />

    </li><li><label class="solo" for="subject">Subject:</label>
    <span class="required">(required)</span> <select class="soloinput" name="subject" id="subject">
    <option value=0> </option>
    <option value=1>General Inquiries</option>
        <option value=2>CAD Services</option>
        <option value=3>Testing/Certification Services</option>
        <option value=4>Inspection/Quality Audits</option>
        <option value=5>Engineering</option>
        <option value=6>DAPIA/IPIA/HUD</option>
        <option value=7>Modular Services</option>
        </select>

    </li><li><label class="solo" for="message">Message:</label>
    <span class="required">(required)</span>
    <div class="soloinput"><textarea class="soloinput" name="message" id="message" ></textarea>
                        <br />
     <input name="submit" id="submit" type="submit" value="Send" style="float: right;" /></div>
    </li></ol>
    </fieldset></form> &nbsp;<br />&nbsp;<br />&nbsp;

以下是PHP&#39;背面&#39; (mailform.php):

 <?php 
    $dontsendemail = 0;
    $possiblespam = FALSE;
    $strlenmessage = "";
    $email = $_REQUEST['email']; 
    $message = $_REQUEST['message']; 

    $subject = array(); 
    $subject[1] = "General Inquiries";
        $subject[2] = "CAD Services";
        $subject[3] = "Testing/Certification Services";
        $subject[4] = "Inspection/Quality Audits";
        $subject[5] = "Engineering";
        $subject[6] = "DAPIA/IPIA/HUD";
        $subject[7] = "Modular Services";
        $subjectindex = $_REQUEST['subject'];
    if ($subjectindex == 0 || !isset($_REQUEST['subject'])) die 
    ("You did not choose a subject line.   Please hit your browser back button and try again.");
    else $subject = $subject[$subjectindex];
    $emailaddress = "wscribner@ntainc.com"; 

    // Check human test input box
    if(isset($_REQUEST["htest"]) && $_REQUEST["htest"] != "") die("Possible spam detected. 
    Please hit your browser back button and check your entries."); 
    // Check email address function
    function checkemail($field) {
    // checks proper syntax
    if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/",
    $field))
    {
    die("Improper email address detected. Please hit your browser back button and enter a proper
    email address."); 
        return 1;
        }
    }
    // Check month function
    function checkmonth($field,$checkrequiredob) {
    if($checkrequiredob == 0) {
    if(!preg_match("/^[\s]   {0,5}$|^(0|January|February|March|April|May|June|July|August|September|October|November|December)$/", $field)) die("Improper month of birth detected. Please hit your browser back button and try again.");  
    }
    else   {if(!preg_match("/^(January|February|March|April|May|June|July|August|September|October|November|December)$/", $field)) die("Improper month of birth detected. Please hit your browser back button and try again."); 
    }
}
// Spamcheck function
function spamcheck($field) {
    if(preg_match("/to:/i",$field) || preg_match("/cc:/i",$field) || preg_match("/\r/i",$field) || preg_match("/i\n/i",$field) || preg_match("/%0A/i",$field)){ 
        $possiblespam = TRUE;
    }else $possiblespam = FALSE;
    if ($possiblespam) {
        die("Possible spam attempt detected. If this is not the case, please edit the content of the contact form and try again.");
        return 1;
    }
}
// Spamcheck URL function
function spamcheckurl($field) {
    if(preg_match("/to:/i",$field) || preg_match("/cc:/i",$field) || preg_match("/\r/i",$field) || preg_match("/\n/i",$field)){ 
        $possiblespam = TRUE;
    }else $possiblespam = FALSE;
    if ($possiblespam) {
        die("Possible spam attempt detected. If this is not the case, please edit the content of the contact form and try again.");
        return 1;
    }
}
function strlencheck($field,$minlength,$maxlength,$minresponse,$maxresponse) {
    if (strlen($field) < $minlength){
        die($minresponse); 
        return 1;
    }
    if (strlen($field) > $maxlength){
        die($maxresponse); 
        return 1;
    }
}
function checkphone($field,$checkrequirephone,$warning) {
    if($checkrequirephone == 0) {
        if(!preg_match("/^([\s]{0,10})$|^(((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?)(((\d{1,12}){1})|((\d{3,4}([-\s\.])?){2,3})){1}([\s]{0,10}))$/", $field)) die($warning);
    }       
    else {
        if(!preg_match("/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?)(((\d{1,12}){1})|((\d{3,4}([-\s\.])?){2,3})){1}([\s]{0,10})$/", $field)) die($warning);
    }
}
function checkpriority($field,$checkrequirepriority) {
    if($checkrequirepriority == 0) {
        if(!preg_match("/^[\s]{0,10}$|^[\d]$/",$field)) die("Improper priority detected. Please hit your browser back button and try again.");
    }
    else {
        if(!preg_match("/^[\d]$/",$field)) die("Improper priority detected. Please hit your browser back button and try again.");
    }
}



        $name = $_REQUEST['name'];strlencheck($name,1,60,"You have not entered a proper name. Please hit your browser back button and check your name entry.","You have entered a name that is too long. Please hit your browser back button and check your name entry.");if ($dontsendemail == 0) $dontsendemail = spamcheck($_REQUEST["htest"]);
        if ($dontsendemail == 0) $dontsendemail = spamcheck($name);

    if ($dontsendemail == 0) $dontsendemail = checkemail($email);
    if ($dontsendemail == 0) $dontsendemail = spamcheck($email);
    if ($dontsendemail == 0) $dontsendemail = spamcheck($subject);
    if ($dontsendemail == 0) $dontsendemail = strlencheck($email,10,255,"The email address field is too short. Please hit your browser back button and check your entry.<br />","The email address you have entered is too long. Please hit your browser back button and check your entry.");

    if ($dontsendemail == 0) $dontsendemail = strlencheck($subject,1,255,"You did not choose a subject. Please hit your browser back button and check your entry.<br />","The subject you have entered is too long. Please hit your browser back button and check your entry.");

    if ($dontsendemail == 0) $dontsendemail = strlencheck($message,10,10000,"The message field is too short. Please hit your browser back button and check your entry.<br />","Your message is limited to 10000 characters. Please hit your browser back button and shorten your message."); 
    if ($dontsendemail == 0) $dontsendemail = strlencheck($emailaddress,8,255,"You have not selected a recipient of your message. Please hit your browser back button and check your entry.<br />","Possible spam detected. Please hit your browser back button and choose a recipient for your email.");
    if ($dontsendemail == 0) {
        $message="";
        $message.="Name: ".$name."\r\n";

        $message=$message."\r\nMessage:\r\n".$_REQUEST['message'];
        mail($emailaddress,"$subject",$message,"From: $email" ); include "emailsent.htm";
    }

然后,用户应该看到一个名为emailsent.htm的页面,其中包含消息&#34;您的消息已成功发送。有人会尽快与您联系!&#34;

我无法在服务器端看到任何导致文件错误的内容。任何帮助表示赞赏!但是,我是PHP编码的新手(虽然我可以编辑),所以请提供很多细节!

0 个答案:

没有答案