• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

RESOLVED PHP Form action Error: 405 Not Allowed

Miro15

New member
Messages
1
Likes
0
Points
1
#1
Hey,
I have a problem, I created a User form to register for an e-mail newsletter, I googled for an answer for the form action with this plugin but only found a solution that didnt worked. The solution was found in the wordpress forum category woody snippets. The form is shown completly right on my website, but if I click on the submit button I get an error message "405 Not Allowed - nginx" and no e-mail was sent to me.

HTML:
<form action="http://111.111.111.111/?wbcr_news_letter" method="post">
    
    1. Anrede <br>

     <select name="anrede">
         <option value="herr">Herr</option>
         <option value="frau">Frau</option>
          <option value="divers">divers</option>
    </select>
    <br>
    <br>
    
    2. Vorname <br>
    
    <input type="text" name="vorname"><br><br>
    
    3. Nachname <br>
    
    <input type="text" name="nachname"><br><br>
    
    4. Firma <br>
    
    <input type="text" name="firma"><br><br>
    
    5. E-Mail <br>
    
    <input type="text" name="email"><br><br>
    
    6. E-Mail Neu <br>
    
    <input type="text" name="emailneu"><br><br>
    
      <input type="radio" name="tatigkeit" value="abonnieren">Abonieren<br>
      <input type="radio" name="tatigkeit" value="ändern">Ändern<br>
    <input type="radio" name="tatigkeit" value="kündigen">Kündigen<br>
    
    <br>
    
    Format: <br>
    
    <input type="radio" name="format" value="text">Nur-Text-Format<br>
    <input type="radio" name="format" value="html">HTML-Format<br>
    
    <br>

      <input type="submit">
</form>


PHP Code:

PHP:
function wbcr_news_letter() {
  if( isset($_GET['wbcr_news_letter']) ) {
      $anrede = $_POST["anrede"];
      $vorname = $_POST["vorname"];
      $nachname = $_POST["nachname"];
      $firma = $_POST["firma"];
      $email = $_POST["email"];
      $emailneu = $_POST["emailneu"];
      $tatigkeit = $_POST["tatigkeit"];
      $format = $_POST["format"];
      
      
      $empfaenger = "name.name@email.de";
      $betreff = "Newsletter";
      $from = "From: name name <name.name@gmail.com>";
      $text = "Anrede: " . $anrede;
 
      mail($empfaenger, $betreff, $text, $from);
      
    exit;
  }
}

add_action('init', 'wbcr_news_letter');

Greetings

Miro :)
 

Temyk

Developer & Support
Messages
1,129
Likes
42
Points
48
#2
Hi!

Maybe because you are trying to send these forms to a strange address http://111.111.111.111/?wbcr_news_letter?
Most likely it should be like this:
HTML:
<form action="/?wbcr_news_letter" method="post">
Error 405 occurs due to server settings. If the error persists, contact your hosting technical support
 
Last edited: