dongwan0574 2017-01-30 20:17
浏览 43
已采纳

联系表格不发送/重定向

Hi I have the below codes , and for some reason redirects and I get a Undefined variable: subject in C:\wamp\www\boot\send.php on line 42, as below. Appreciate any assistance I can get.

Line 42 is

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

Contact us

    <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."
";

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

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


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

if($go) {

    print("message sent");
}

else{

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

?>
  • 写回答

3条回答 默认 最新

  • douxian6008 2017-01-30 20:33
    关注

    The reason it's not directing you to the send.php is caused by the two form tags. The first form tag will run first and be the reason why it's staying on the same page. To stop this confusion you could give the form an id (like class) using the div tag:

    <div id="contact-form">
    <form action="send.php" method="post">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算