html — ошибка HTTP 405 при отправке формы PHP

Я управляю веб-сайтом лагеря, который имеет форму, которая позволяет вам забронировать место там. Данные из формы затем отправляются по электронной почте с помощью метода PHP mail (). Я знаю, что это, вероятно, не самое лучшее / самое безопасное решение, но я не очень разбираюсь в PHP и до сих пор он работал. Недавно, однако, форма начала выдавать ошибку 405 при отправке. Это какая-то проблема с моим PHP?

Это HTML-код для формы:

    <div class="container" id="main">

<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid" id="navbar_container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#hlavni_navigace">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html" style="padding-top:8px">
<img class="logo" src="../img/ejpovice_drawing_250.png">
</a>
<a class="navbar-brand" href="index.html"  style="letter-spacing:-0.1px;">
Autocamp
</a>
</div>
<div class="collapse navbar-collapse" id="hlavni_navigace" aria-expanded="false">
<ul class="nav navbar-nav">
<li><a href="index.html" >Home</a></li>
<li style="width:20%"><a href="accommodation.html">Accommodation</a></li>
<li><a href="gallery.html">Gallery</a></li>
<li class="active"><a href="reservations.html" class="active">Reservations<span class="sr-only">(current)</span></a></li>
</ul>

</div>
</div>
</nav>
<div class="objednavkovy_formular" style="margin-top:80px">
<div class="vnitrni_formular">

<form class="formular" method="POST" action='rezervace.php'>
<div class="form-group">
<label for="name">First name and surname: *</label><br>
<div class="input-group">
<input size="100" type="text" name="name" id="name" class="form-control" placeholder="Full name..." required>
<br>
</div>
</div>

<div class="form-group">
<label for="email">Email address: *</label><br>
<div class="input-group">
<input size="100" type="text" name="email" id="email" class="form-control" placeholder="[email protected]" value="@" required>
</div>
</div>

<div class="form-group">
<label for="telefon">Phone number: </label><br>
<div class="input-group">
<input type="text" name="telefon" id='telefon' class='form-control' placeholder='123456789'>
</div>
</div>

<div class="form-group">
<label for="od">From *</label>
<label for="do" style="margin-left:21%;">To: *</label><br>
<div class="input-group">
<script>
$(function() {
$( "#datepicker" ).datepicker({dateFormat: 'dd/mm/yy'});
});

$(function() {
$( "#datepicker2" ).datepicker({dateFormat: 'dd/mm/yy'});
});
</script>
<input type="text" name ="od" id="datepicker" size="100" style="height:0px;width:20%;" required>
<input type="text" name="do" id="datepicker2" size="100" style="height:0px;width:20%;margin-left:50px;" required>
</div>
</div>

<div class="form-group">
<label for="typ">Accommodation type: *</label><br>
<div class="input-group">
<select name="typ" style="color:#555;border:none;font-size:14px;padding:20px;" required>
<option value="nespecifikovano">--||--</option>
<option value="Karavan">Caravan</option>
<option value="Obyt_auto">Motorhome</option>
<option value="Stan">Tent</option>
<option value="Chata">Bungalow</option>
</select>
</div>

</div>

<div class="form-group">
<label for="pocet-lidi">Number of guests:</label><br>
<div class="input-group">
<input name="pocet-lidi" type="text" class="form-control" style="width:38%;color:#555;">
</div>

</div><div class="form-group">
<label for="poznamky">Notes:</label><br>
<div class="input-group" style="width:71%;">
<textarea cols="1" style="resize:none;padding-right: 12px;padding-left:12px;padding-top:6px;padding-bottom:6px;" rows="3" name="poznamky" id="poznamky" class="form-control" placeholder="Special requests - fridge ..."></textarea>
</div>
</div>
<input type="submit" name="submit" id="submit" value="Send" class="btn btn-primary" style="padding:15px;">
<?php
if ($success) {
echo $success;
}
?>
</form>
</div>

</div>
</div>
</div>

</body>

И это PHP, который обрабатывает форму

<?php
if(isset($_POST['email'])) {

$email_to = "[email protected]";
$email_subject = "Reservation";function died($error) {

echo "We are sorry but your form contains errors and cannot be sent. ";
echo "The errors are the following: <br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix the errors in the form.<br /><br />";
die();
}if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['poznamky']) ||
!isset($_POST['od']) ||
!isset($_POST['do'])) {
died('We are sorry but the form contains a mistake.');
}

$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$poznamky = $_POST['poznamky']; // required
$od = $_POST['od'];
$do = $_POST['do'];
$typ = $_POST['typ'];
$cislo = $_POST['telefon'];
$host = $_POST['pocet-lidi'];
$from_email_address = "[email protected]";

$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= "Your email address isn't valid.<br />";
}
$string_exp = "/^[A-Za-zá-žÁ-Ž .'-]+$/";
if(!preg_match($string_exp,$name)) {
$error_message .= 'Your name is not written in a valid way.<br />';
}

if(strlen($error_message) > 0) {
died($error_message);
}

if(strlen($host) > 2){
$error_message .= 'The number of guests is not valid. <br />';
}
$pocet_exp="/^[0-9]$/";
if (!preg_match($pocet_exp,$host)){
$error_message .= 'The number of guests is not valid. <br />';
}
$cislo_exp="/^[0-9]$/";
if (!preg_match($cislo_exp,$cislo)){
$error_message .= 'The phone number is not valid <br />';
}$email_message = "Reservation confirmation:<br><br>";
$email_message2 = "Hi, <br> this email confirms your following reservation at Autocamp:<br><br>";

function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}

$email_message .= "Full name: ".clean_string($name)."<br>";
$email_message .= "Email: ".clean_string($email_from)."<br>";
$email_message .= "Phone number: ".clean_string($cislo)."<br>";
$email_message .= "From: ".clean_string($od)."<br>";
$email_message .= "To: ".clean_string($do)."<br>";
$email_message .= "Accommodation type: ".clean_string($typ)."<br>";
$email_message .= "Number of guests: ".clean_string($host)."<br>";
$email_message .= "Notes: ".clean_string($poznamky)."<br>";

$email_message2 .= "Full name: ".clean_string($name)."<br>";
$email_message2 .= "Email: ".clean_string($email_from)."<br>";
$email_message2 .= "Phone number: ".clean_string($cislo)."<br>";
$email_message2 .= "From: ".clean_string($od)."<br>";
$email_message2 .= "To: ".clean_string($do)."<br>";
$email_message2 .= "Accommodation type: ".clean_string($typ)."<br>";
$email_message2 .= "Number of guests: ".clean_string($host)."<br>";
$email_message2 .= "Notes: ".clean_string($poznamky)."<br><br>";

$email_message2 .= "Thank you for your reservation and see you soon!";$headers = 'From: '.$from_email_address."\r\n";
$headers .= 'Content-Type: text/html; charset="UTF-8"'."\r\n";@mail($email_to, $email_subject, $email_message, $headers);
@mail($email_from, $email_subject, $email_message2, $headers);
header('Location: rezervace-success.html');

?>

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы [email protected]