我一直在努力獲得一個簡單的聯繫表單與引導工作,但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;
}
?>
正在使用什麼方法?它看起來像表單使用'POST',但這可能會被javascript修改。 – Mike
是的,我相信這是使用POST –
你在process.php上得到了。那在哪裏? – nerdlyist