php文件提交按钮没有发送响应

时间:2015-01-02 18:40:22

标签: php html

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

请帮忙......谢谢

<?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 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Time<br>

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

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

    12 feb,2015 &nbsp; &nbsp; &nbsp; 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 : &nbsp; &nbsp; &nbsp; Islamabad <input type = "radio" name = "location" <?php if 

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

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

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

        Do you want travel facility ? &nbsp; &nbsp; &nbsp;

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

        Do you want hotel facility ? &nbsp; &nbsp; &nbsp;

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

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

        <input type="reset" >

   </form>

3 个答案:

答案 0 :(得分:1)

基本PHP 101:变量名称区分大小写

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

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

答案 1 :(得分:1)

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

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

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

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

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

答案 2 :(得分:0)

您尚未关闭else条件

在文件末尾关闭else标签

</form>
<?php }

并按照Marc BDeryck's指南

进行操作