我一直在努力尝试使用自举工作制作一个简单的联系表单,但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 = 'mark.bauer@med.fsu.edu';
$email = 'email@example.com';
$fromaddress = "you@example.com";
$fromname = "Online Contact";
require("phpmailer.php");
$mail = new PHPMailer();
$mail->From = "mark.bauer@med.fsu.edu";
$mail->FromName = "Mark Bauer";
$mail->AddAddress("mark.bauer@med.fsu.edu","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 = 'mark.bauer@med.fsu.edu';
$subject = 'Contact form failed';
$content = $body;
mail($recipient, $subject, $content, "From: mail@yourdomain.com\r\nReply-To: $email\r\nX-Mailer: DT_formmail");
exit;
}
?>
答案 0 :(得分:0)
POST方法经常出现405错误。您可能正在尝试在网站上引入某种输入表单,但并非所有ISP都允许使用必要的POST方法来处理表单。
所有405错误都可以追溯到Web服务器的配置和管理网站内容访问的安全性,因此您的ISP应该很容易解释。