php 文件提交按钮未发送响应

php file submit button not sending response

在我的代码中有一个 html 表单。我想通过电子邮件发送回复并在点击按钮时显示一行 "your message was send",但它不起作用...当我点击发送回复按钮时没有任何反应。

请帮忙...谢谢

<?php 
 if (isset($_post['send'])) { 
  $ToEmail = 'abc@gmail.com'; 
  $EmailSubject = 'Site contact form'; 
  $mailheader = "From: ".$_POST["email"]."\r\n"; 
  $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; 
  $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
  $check_list1 = $_POST['check_list1'];
   if ($check_list1 != 'Yes') {
     $check_list1 = 'No';
   }
  $check_list2 = $_POST['check_list2'];
   if ($check_list2 != 'Yes') {
    $check_list2 = 'No';
   }

  $MESSAGE_BODY = "Date ".$_POST["dat"]."";
  $MESSAGE_BODY .= "Location ".$_POST["location"]."";

  mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
  ?> 
 Your message was sent
<?php 

} else { 
?> 
 <h1><center>Meeting Invitation</center></h1>
   <form action="my.php" method="post">
      You are invited for the meeting on company crisis
       proposed dates are :<br><br>

    Date                  Time<br>

    10 jan,2015       10.00 am<input type = "radio" name = "dat" <?php if    

   (isset($dat) && $dat=="val1") echo "checked";?> value = "val1" checked="true" ><br>

    12 feb,2015       12.15 am<input type = "radio" name = "dat" <?php if 

   (isset($dat) && $dat=="val2") echo "checked";?> value = "val2" ><br><br>

    Proposed locations are :<br>

    Location 1 :       Islamabad <input type = "radio" name = "location" <?php if 

  (isset($location) && $location=="val1") echo "checked";?>  value = "val1" checked="true" ><br>

    Location 2 :       Rawalpindi <input type = "radio" name = "location" <?php if 

     (isset($location) && $location=="val2") echo "checked";?>  value = "val2" ><br><br>

        Do you want travel facility ?      

     <input type="checkbox" name="check_list1" value="yes"> <br><br>

        Do you want hotel facility ?      

        <input type="checkbox" name="check_list2" value="yes"> <br><br><br>

        <input type="button" name="send" value="Send Response">

        <input type="reset" >

   </form>

基本PHP101:变量名区分大小写

 if (isset($_post['send'])) { 
            ^^^^^--- undefined variable

应该是$_POST。如果您打开了 display_errors 和 error_reporting,您会收到有关使用未定义变量的警告,并将该未定义变量视为数组。首先,devel/debug 系统上的调试选项永远不应该关闭。

<input type="button" name="send" value="Send Response">

类型必须是提交,除非您在 Javascript 中有单独的事件处理程序来发送数据。

<input type="submit" name="send" value="Send Response">

否则除鼠标点击外不会触发任何事件

是的,您的 PHP 需要 $_POST 而不是 $_post 但这并不是真正影响发送按钮无响应的原因。

您还没有关闭您的 else 条件

在文件末尾关闭 else 标签

</form>
<?php }

并遵循 Marc BDeryck's 指南