【问题标题】:404 error contact form bootstrap404 错误联系表单引导程序
【发布时间】:2014-11-02 00:12:07
【问题描述】:

在阅读了每篇论坛帖子后,我仍然无法弄清楚如何让我的联系表正常工作。我的前端部分看起来不错,但每次尝试使用它时都会收到 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
}
?>

【问题讨论】:

  • 看起来很明显。你的页面叫contact_us.php而不是contact.php,那你为什么要重定向到contact.php
  • 哇!非常感谢,我想我只是看代码太多,下意识地一直错过。

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


【解决方案1】:

您的服务器上没有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
}

【讨论】:

    猜你喜欢
    • 2018-12-24
    • 1970-01-01
    • 2020-12-25
    • 1970-01-01
    • 2018-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多