PHP表单处理程序在同一文档中

时间:2016-06-30 19:30:55

标签: php forms

我正在尝试使用此联系表单来处理同一文档中的操作。

这就是我目前所拥有的:

<?php
        function submitfunc() {
$EmailTo = prep($sObj->email);
$Subject = "The reason why your submission got rejected.";
$Message = Trim(stripslashes($_POST['Message'])); 
$header = "From: info@website.com\r\n"; 
$header.= "MIME-Version: 1.0\r\n"; 
$header.= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 
$header.= "X-Priority: 1\r\n"; 

// prepare email body text
$Body = "";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, $header);

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=succes.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
        } 
?>  


    <?php   
        if(isset($_GET['action'])=='submitfunc') {
            submitfunc();
        }else { ?>
            <form method="post" action="?action=submitfunc">
                <textarea placeholder="Describe why the image got rejected..." name="Message" rows="3" cols="20" id="Message"></textarea>
                <input type="submit" name="submit" value="No + send message" class="btn btn-large btn-danger"  />
            </form>

    <?php } ?>

每当我尝试运行它时,我都会进入error.htm页面。 我该如何解决这个问题?

编辑:我已将$ header添加到我的邮件中。仍然没有工作。

0 个答案:

没有答案