5 replies
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

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

  mail( "myemail@myemail.com", "Feedback Form Results",
    $message, "From: $email" );
  header( "Location: URL" );
?>
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

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>
#405 #error #http
  • Profile picture of the author Tashi Mortier
    It definitely seems as there is a problem with your hosting.

    Error 405 means that the HTTP method (get/post/put/delete, in your case post) isn't supported. You should try to run the script in a local environment like XAMPP and if there are no errors there (besides the e-mail not getting delivered) then you should complain to your hoster.
    Signature

    Want to read my personal blog? Tashi Mortier

    {{ DiscussionBoard.errors[3529302].message }}
  • Try changing the method to get instead of post.

    <form method="get" action="sendmail.php">

    if that doesnt work. Contact hosting support, or get a new host.

    I can get you setup with us on a free one month trial if you like.
    {{ DiscussionBoard.errors[3531589].message }}
    • Profile picture of the author Tashi Mortier
      Originally Posted by Cash Money Hosting View Post

      Try changing the method to get instead of post.

      <form method="get" action="sendmail.php">

      if that doesnt work. Contact hosting support, or get a new host.

      I can get you setup with us on a free one month trial if you like.
      Don't forget to change the variables from $_POST to $_GET then. Though I think that this is an unacceptable flaw if you can't use the post method.

      The message will be transported via the URL of the form then and so someone might accidentally send you the message many times.
      Signature

      Want to read my personal blog? Tashi Mortier

      {{ DiscussionBoard.errors[3534826].message }}
      • Originally Posted by Tashi Mortier View Post

        Though I think that this is an unacceptable flaw if you can't use the post method.
        I agree, but I saw on the web that some hosting companies dont allow the POST method. Crazy, but true.
        {{ DiscussionBoard.errors[3538015].message }}
        • Profile picture of the author Tashi Mortier
          Even though that goes a bit off-topic. What security gains does that offer? I can limit the upload size and security flaws can usually also be exploited via GET.

          I have never heard of anything like this before. GET and POST are both methods that should always be allowed, I could understand if they blocked the other methods, because they are often times only used in WebDav.
          Signature

          Want to read my personal blog? Tashi Mortier

          {{ DiscussionBoard.errors[3542866].message }}

Trending Topics