Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

264
Visualizações
405 HTTP Error on submitting data on PHP / HTML form

I am building a form that the filled data need to be sent to an email. I am using HTML and PHP. But Unfortunately I get the following error when I press SUBMIT button.

405 - HTTP verb used to access this page is not allowed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access

The PHP code is :

<?php

if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $visitor_email = $_POST['email'];
    $message = $_POST['message'];
    
    $email_subject = "NEW MESSAGE VIA CONTACT FORM";
    
    $email_body = "You have received a new message from the user ".$name. ".\n".$message;
    
    $to = "info@house.gr"
    $headers = "From: ".$visitor_email;
    
    mail($to, $email_subject, $email_body, $headers);
    header("Location: index.html?mailsend");
}
?>

The HTML form is :

<form method="POST" class="contact-form" actions="contactform.php">
                                <input type="text" name="name" placeholder="Full Name">
                                <input type="text" name="mobile" placeholder="Your Mobile Phone">
                                <input type="text" name="email" placeholder="Your E-mail">
                                <textarea class="materialize-textarea" name="message" placeholder="Your Message"></textarea>
                                <input type="submit" value="Submit" class="btn">
                            </form>

UPDATE: with this edit on code: action="contactform.php" , I dont get the error but the email is not send

FINAL SOLUTION: Changed the php file to this:

    $headers = "From: ";
    $headers .= $visitor_email;
    
    mail($to, $email_subject, $email_body, $headers);
    header('Location: ../');

I found the problem via the log files in the webserver

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

maybe you wrote actions instead of action in the form's attribute

actions="contactform.php"

should be

action="contactform.php"
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda