404错误联系表单引导程序

时间:2014-09-08 17:36:34

标签: php html twitter-bootstrap http-status-code-404 contact-form

在阅读了每篇论坛帖后,我仍然无法弄清楚如何让我的联系表格正常工作。我得到它的前端部分看起来不错,但每次我尝试使用它时都会出现404错误。显然,因为提交的信息都没有通过。这是我的代码:

这是我的contact.php,其中有一个

<script src="email/validation.js" type="text/javascript"></script>

位于标题

之间的顶部
<div class="span12" id="divMain">
     <div id="contact"> 
      <h1>Contact Us</h1></div>
         <h3 style="color:#FF6633;"><?php echo $_GET[msg];?></h3>
   <hr>
<!--Start Contact form -->                                                      
 <form name="enq" method="post" action="email/index.php" onsubmit="return     
           validation();">
 <fieldset>    

<input type="text" name="name" id="name" value=""  class="input-block-level"    placeholder="Name" />

<input type="text" name="email" id="email" value="" class="input-block-level"  placeholder="Email" />
 <textarea rows="9" name="message" id="message" class="input-block- levelplaceholder="Let's hear what you've got to say"> </textarea>
<div class="actions">
    <input type="submit" value="Send" name="submit" id="submitButton" class="btn btn-success pull    -right" title="Click here to submit your message!" />
     </div> 
</fieldset>
    <hr>
     </form>                 
<!--End Contact form -->                                             
    </div>

接下来是我的validation.js

function validation()
 {
var contactname=document.enq.name.value;
var name_exp=/^[A-Za-z\s]+$/;
if(contactname=='')
{
    alert("Name Field Should Not Be Empty!");
    document.enq.name.focus();
    return false;
}
else if(!contactname.match(name_exp))
{
    alert("Invalid Name field!");
    document.enq.name.focus();
    return false;
}

var email=document.enq.email.value;
//var email_exp=/^[A-Za-z0-9\.-_\$]+@[A-Za-z]+\.[a-z]{2,4}$/;
var email_exp=/^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
if(email=='')
{
    alert("Please Enter Email-Id!");
    document.enq.email.focus();
    return false;
}
else if(!email.match(email_exp))
{
    alert("Invalid Email ID !");
    document.enq.email.focus();
    return false;
}


var message=document.enq.message.value;
if(message=='')
{
    alert("Query Field Should Not Be Empty!");
    document.enq.message.focus();
    return false;
}
return true; }

关注我的index.php

<?php
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$query = $_POST['message'];
$email_from = $name.'<'.$email.'>';

$to="marketing@durangoconnections.com";
$subject="Enquiry!";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: ".$email_from."\r\n";
$message="    

     Name:
     $name     
     <br>
     Email-Id:
     $email        
     <br>
     Message:
     $query        
    ";
 if(mail($to,$subject,$message,$headers))
    header("Location:../contact.php?msg=Successful Submission! Thankyou for contacting     us.");
else
    header("Location:../contact.php?msg=Error To send Email !");
    //contact:-your-email@your-domain.com
}
?>

1 个答案:

答案 0 :(得分:2)

您的服务器上没有contact.php个文件,您的意思是contact_us.php

if(mail($to,$subject,$message,$headers))
    header("Location:../contact_us.php?msg=Successful Submission! Thankyou for contacting     us.");
else
    header("Location:../contact_us.php?msg=Error To send Email !");
    //contact:-your-email@your-domain.com
}