简体   繁体   English

Bootstrap PHP联系表格未提交并给出405错误

[英]Bootstrap PHP contact form not submitting and giving 405 error

I've been working on trying to get a simple contact form made with bootstrap working but PHP is a bit over my head and I can't seem to figure out why nothing is being submitted. 我一直在努力尝试使用Bootstrap制作一个简单的联系表格,但是PHP有点麻烦,而且我似乎无法弄清楚为什么什么都没提交。 When I inspect the code I see a "405 Method Not Allowed" error is occurring somewhere, but I don't know how to track down. 当我检查代码时,我看到某个地方发生“ 405方法不允许”错误,但是我不知道如何追踪。 Any help would be greatly appreciated. 任何帮助将不胜感激。

Here is the site and form in question: https://actsdisplay.med.fsu.edu/NewSite/contact.html 这是有问题的站点和表单: https : //actsdisplay.med.fsu.edu/NewSite/contact.html

Here is my PHP code: 这是我的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;
}
?>

405 errors often arise with the POST method. POST方法通常会出现405错误。 You may be trying to introduce some kind of input form on the Web site, but not all ISPs allow the POST method necessary to process the form. 您可能正在尝试在Web站点上引入某种输入形式,但是并非所有ISP都允许处理该形式所必需的POST方法。

All 405 errors can be traced to configuration of the Web server and security governing access to the content of the Web site, so should easily be explained by your ISP. 可以将所有405个错误追溯到Web服务器的配置和控制对网站内容的访问的安全性,因此,您的ISP应该很容易地解释一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM