HTTP Error - 405

So I don’t know too much about PHP or creating forms, this is my first try here. I’m using a Network Solutions web hosting. When ever I submit the form it goes to my sendmail.php page and give me an HTTP Error - 405 (page cannot be displayed) and never sends the form.

Here’s the code I’m using


<?php
  $email = $_POST['email'];
  $message = $_POST['message'];

  mail( "myemail@myemail.com", "Feedback Form Results",
    $message, "From: $email" );
  header( "Location: http://www.google.com" );
?>

Very simple. I don’t think the problem would lie in the HTML. Anyone have a solution to my problem? Where do I go from here?

HTML Code


<form method="post" action="sendmail.php"> 
  Email: <input name="email" type="text" /><br /> 
  Message:<br /> 
  <textarea name="message" rows="15" cols="40"> 
  </textarea><br /> 
  <input type="submit" /> 
</form>

can i put sendmail.php on another server and connect it with the form that way?

:confused: im not too familiar with PHP, what do you mean “sanitize”?

So it’s not letting me send it because the name isn’t long enough/too simple?

HTTP 405 means ‘Method not allowed’.

It might mean that POSTing to scripts called sendmail.php is not allowed. Try renaming sendmail.php to a more difficult to spam file name.

I’m not sure, if you really want to be certain then you should ask your host.

But I’m guessing that POSTing data to files called sendmail.php is disabled. Lots of spam scripts search for files called sendmail.php, which is why it might be blocked.

Try calling it something like ‘contactformhandler.php’. If changing the name doesn’t work, then you should probably ask your host.

Also, you should sanitize $email before sending the mail. A mail script could easily use your form to send 1000’s of spam messages…