2016-08-30 121 views
0

我一直在努力获得一个简单的联系表单与引导工作,但PHP是有点超过我的头,我似乎无法弄清楚为什么没有正在提交。当我检查代码时,我发现“405方法不允许”错误发生在某处,但我不知道如何跟踪。任何帮助将不胜感激。Bootstrap PHP联系表格不提交和给405错误

这里是有问题的网站和形式:https://actsdisplay.med.fsu.edu/NewSite/contact.html

这是我的PHP代码:

<?php 
if ((isset($_POST['interest'])) && (strlen(trim($_POST['interest'])) > 0)) { 
    $name = stripslashes(strip_tags($_POST['interest'])); 
} else {$name = 'No interest selected';} 
if ((isset($_POST['name'])) && (strlen(trim($_POST['name'])) > 0)) { 
    $name = stripslashes(strip_tags($_POST['name'])); 
} else {$name = 'No name entered';} 
if ((isset($_POST['email'])) && (strlen(trim($_POST['email'])) > 0)) { 
    $email = stripslashes(strip_tags($_POST['email'])); 
} else {$email = 'No email entered';} 
if ((isset($_POST['phone'])) && (strlen(trim($_POST['phone'])) > 0)) { 
    $message = stripslashes(strip_tags($_POST['phone'])); 
} else {$message = 'No phone entered';} 
ob_start(); 
?> 
<html> 
<head> 
<style type="text/css"> 
</style> 
</head> 
<body> 
<table width="550" border="1" cellspacing="2" cellpadding="2"> 
    <tr bgcolor="#eeeeff"> 
    <td>Interest</td> 
    <td><?=$interest;?></td> 
    </tr> 
    <tr bgcolor="#eeffee"> 
    <td>Name</td> 
    <td><?=$name;?></td> 
    </tr> 
    <tr bgcolor="#eeeeff"> 
    <td>Email</td> 
    <td><?=$email;?></td> 
    </tr> 
    <tr bgcolor="#eeeeff"> 
    <td>Phone</td> 
    <td><?=$phone;?></td> 
    </tr> 
    <tr bgcolor="#eeffee"> 
    <td>Message</td> 
    <td><?=$message;?></td> 
    </tr> 
</table> 
</body> 
</html> 
<? 
$body = ob_get_contents(); 

$to = '[email protected]'; 
$email = '[email protected]'; 
$fromaddress = "[email protected]"; 
$fromname = "Online Contact"; 

require("phpmailer.php"); 

$mail = new PHPMailer(); 

$mail->From  = "[email protected]"; 
$mail->FromName = "Mark Bauer"; 
$mail->AddAddress("[email protected]","Med"); // Put your email 

$mail->WordWrap = 50; 
$mail->IsHTML(true); 

$mail->Subject = "Contact form submitted"; 
$mail->Body  = $body; 
$mail->AltBody = "This is the text-only body"; 

if(!$mail->Send()) { 
    $recipient = '[email protected]'; 
    $subject = 'Contact form failed'; 
    $content = $body; 
    mail($recipient, $subject, $content, "From: [email protected]\r\nReply-To: $email\r\nX-Mailer: DT_formmail"); 
    exit; 
} 
?> 
+0

正在使用什么方法?它看起来像表单使用'POST',但这可能会被javascript修改。 – Mike

+0

是的,我相信这是使用POST –

+0

你在process.php上得到了。那在哪里? – nerdlyist

回答

0

405错误通常用POST方法出现。您可能试图在Web站点上引入某种输入表单,但并非所有ISP都允许处理表单所需的POST方法。

所有405个错误都可以追溯到Web服务器的配置以及管理访问Web站点内容的安全性,所以应该由您的ISP轻松解释。

+0

好的,我会研究一下。谢谢 –