联系表格不发送/重定向

时间:2017-01-30 20:17:43

标签: php html css

嗨我有以下代码,由于某种原因重定向,我得到一个未定义的变量:主题在第42行的C:\ wamp \ www \ boot \ send.php中,如下所示。感谢我能得到的任何帮助。

第42行

$go = mail($to, $subject, $body, "From:<$from>");

联系我们

    <body>
<div class='formbody'>

<link href='http://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>

<form id="contact-form" action="send.php" method="POST">

  <p>Dear hidden@gmai..com,</p>
  <p>My
    <label for="your-name">name</label> is
    <input type="text" name="your-name" id="your-name" minlength="3" placeholder="(your name here)" required> and</p>

  <p>my
    <label for="email">email address</label> is
    <input type="email" name="your-email" id="email" placeholder="(your email address)" required>
  </p>

  <p> I have a
    <label for="your-message">message</label> for you,</p>

  <p>
    <textarea name="your-message" id="your-message" placeholder="(your msg here)" class="expanding" required></textarea>
  </p>
  <p>
    <button type="submit">
      <svg version="1.1" class="send-icn" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100px" height="36px" viewBox="0 0 100 36" enable-background="new 0 0 100 36" xml:space="preserve">
        <path d="M100,0L100,0 M23.8,7.1L100,0L40.9,36l-4.7-7.5L22,34.8l-4-11L0,30.5L16.4,8.7l5.4,15L23,7L23.8,7.1z M16.8,20.4l-1.5-4.3
    l-5.1,6.7L16.8,20.4z M34.4,25.4l-8.1-13.1L25,29.6L34.4,25.4z M35.2,13.2l8.1,13.1L70,9.9L35.2,13.2z" />
      </svg>
      <small>SEND PLEASE</small>
    </button>
  </p>
</form>
    <script src="assets/js/jquery.min.js"></script>
    <script src="assets/bootstrap/js/bootstrap.min.js"></script>
    <script src="assets/js/bs-animation.js"></script>
     <script src="assets/js/index.js"></script>
    </div>
</body>

Send.php

    <?php
$to = "hidden@gmail.com";
$name = TRIM (stripslashes($_POST['your-name']));
$email = TRIM (stripslashes($_POST['your-email']));
$message = TRIM (stripslashes($_POST['your-message']));

$body ="";
$body .="Name: ";
$body .=$name;
$body."\n";

$body ="";
$body .="Email: ";
$body .=$email;
$body."\n";

$body ="";
$body .="Message: ";
$body .=$message;
$body."\n";


$go = mail($to, $subject, $body, "From:<$from>");

if($go) {

    print("message sent");
}

else{

    print("There has been a small error . Sorry!!");
}

?>

3 个答案:

答案 0 :(得分:0)

您需要压缩2个表单标记:

<form id="contact-form">
<form action="send.php" method="post">

成一个:

<form id="contact-form" action="send.php" method="post">

答案 1 :(得分:0)

删除<section> <p>"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo."</p> </section> <div class="image"></div> <section> <p>"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta."</p> <br><br> <p>"Sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est."</p> </section>。这导致了一个不存在的额外形式。尝试将其更改为<form id="contact-form">,或将其放入其他表单标记中,然后就可以了。

答案 2 :(得分:0)

它没有将你引导到send.php的原因是由两个表单标签引起的。第一个表单标签将首先运行,并且是它保持在同一页面上的原因。为了避免这种混淆,你可以使用div标签给表单一个id(比如class):

<div id="contact-form">
<form action="send.php" method="post">