PHP联系表单中的500内部错误

时间:2017-11-04 09:12:00

标签: php html contact-form

我已经将这个php编码用于我最近用于我们客户联系页面的联系表单,当我测试页面时,单击提交按钮会出现此错误:

尝试使用ErrorDocument处理请求时遇到

500内部服务器错误错误。

HTML

<form action="contact.php" method="post" name="contact_form" onSubmit="return validate(this);" >
        <div class="contact-form-field cnt-field1">
            <label>Name:</label>
            <input type="text" name="name" class="contact-form-input">
        </div>
        <div class="contact-form-field cnt-field1 cnt-marrght">
            <label>Last Name:</label>
            <input type="text" name="l_name" class="contact-form-input">
        </div>
        <div class="contact-form-field">
            <label>Email:</label>
            <input type="text" name="email" class="contact-form-input">
        </div>
        <div class="contact-form-field">
            <label>Message:</label>
            <textarea class="contact-form-message" name="message"></textarea>
        </div>

        <input type="submit" class="contact-send-btn" value="Send">
    </form>

PHP

<?php
@extract($_POST);
$mailto="motaalmosleh@live.com";
        //$mailto="name@domain.com"; //change e-mail address
        $subject="New Request From NARTC Website";
      $from = "From:";
          $from.=$_POST['email'];
       $headeruser="Mime-Version: 1.0\r\n";
       $headeruser.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
       $headeruser .= "From: $req_txt_first_name <".$email.">" . "\r\n"; //change e-mail address
    $message="<html>
        <head>
        <style>.email {
                    font-family: Verdana, Arial, Helvetica, sans-serif;
                    font-size: 12px;
                    text-align:left;
                    padding-left:10px;
                    color:#000000;
                  }

                  .text{
                    font-family: Verdana, Arial, Helvetica, sans-serif;
                    font-size: 12px;
                    font-weight:bold;
                    text-align:left;
                    padding-left:6px;
                    color:#000000;
                  } 
                  td{
                       vertical-align:top;
                  }
          </style>
        <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
        </head>
        <body>
           <table width='100%' align='center' border='0' cellpadding='0' cellspacing='0'>
<tr><td colspan='2' class='email'></td></tr>
<tr> <td colspan='2'>&nbsp;</td></tr>
<tr><td colspan='2'>&nbsp;</td></tr>
<tr>
  <td colspan='2' class='email'>&nbsp;New Query Submited ! :</td>
</tr>
<tr><td colspan='2'>&nbsp;</td></tr>
<tr>
  <td class='text' width='34%'>&nbsp;<b>Name : </b></td>
  <td class='email' width='66%'>&nbsp;".stripslashes(htmlentities($name))."</td>
</tr>
<tr>
  <td class='text'>&nbsp;<b>Last Name : </b></td>
  <td class='email'>&nbsp;".stripslashes(htmlentities($l_name))."</td>
</tr>
<tr>
  <td class='text'>&nbsp;<b>Comment : </b></td>
  <td class='email'>&nbsp;".stripslashes(htmlentities($email))."</td>
</tr>
<tr>
  <td class='text'>&nbsp;<b>Message : </b></td>
  <td class='email'>&nbsp;".stripslashes(htmlentities($message))."</td>
</tr>


<tr>
<tr><td colspan='2'>&nbsp;</td></tr>
</table>
        </body>
        </html>";


mail($mailto,$subject,$message,$headeruser)or die(error);?>
<script type="text/javascript">
alert("Your message sent successfuly");
window.location.replace('<?=$_SERVER['HTTP_REFERER'];?>');
</script>

JS

<script>
      function trim(str)
{
    return str.replace(/^\s*|\s*$/g,"");
}
function validate_email(email) 
{
    var rxp =/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/;
    if(rxp.test(email)!=true) 
    {
        return false;
    } 
    else 
    {
        return true;
    }
}
function validate() 
{
    if (trim(document.contact_form.name.value) == "") 
    {
        alert("\nPlease Enter Name.")
        document.contact_form.name.focus();
        return false;
    }
        if (trim(document.contact_form.l_name.value) == "") 
    {
        alert("\nPlease Enter Last Name.")
        document.contact_form.l_name.focus();
        return false;
    }


    if (trim(document.contact_form.email.value) == "") 
    {
        alert("\nPlease Email Address.")
        document.contact_form.email.focus();
        return false;
    }
    if (trim(document.contact_form.email.value) != "") 
    {
        if(validate_email(document.contact_form.email.value) == false)
        {
            alert("\nPlease enter valid email address.")
            document.contact_form.email.focus();
            return false;
        }
    }


    if (trim(document.contact_form.message.value) == "") 
    {
        alert("\nPlease Enter Message.")
        document.contact_form.message.focus();
        return false;
    }



}
      </script>

0 个答案:

没有答案