HTTP Error - 405

  • Howdy_McGee
  • Novice
  • Novice
  • Howdy_McGee
  • Posts: 16

Post 3+ Months Ago

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 (This form won't let me use my email so in place of it I just put 'My Email')
(I can't use the link to my thank you page so in place I just put 'My Thankyou Page')

Code: [ Select ]
 $email = $_POST['email'];
 $message = $_POST['message'];

 mail( "My Email", "Feedback Form Results",
  $message, "From: $email" );
 header( "Location: My Thankyou Page" );
  1. <?php
  2.  $email = $_POST['email'];
  3.  $message = $_POST['message'];
  4.  mail( "My Email", "Feedback Form Results",
  5.   $message, "From: $email" );
  6.  header( "Location: My Thankyou Page" );
  7. ?>

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?


Code: [ Select ]
<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" />
  1. <form method="post" action="sendmail.php">
  2.  Email: <input name="email" type="text" /><br />
  3.  Message:<br />
  4.  <textarea name="message" rows="15" cols="40">
  5.  </textarea><br />
  6.  <input type="submit" />
  7. </form>
  • natas
  • PHP Ninja
  • Proficient
  • natas
  • Posts: 308
  • Loc: AFK

Post 3+ Months Ago

I copied your code and used it on my website just to test it and for some reason the "header" function doesn't work for me. I admit I don't really understand the inner workings of it but the error code says that headers were already sent.

I instead used a meta refresh i.e. :
<meta http-equiv="refresh" content="2;url=">

and this works perfectly.

Although I'm not understanding why you just don't build a thank you page and include the php coding to process the email inside that same page. This would be a lot better than processing the email and then redirecting.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9129
  • Loc: Seattle, WA

Post 3+ Months Ago

A 405 error means "method not allowed" which means the method of "post" in your HTML form that you set is for some reason not being allowed by the server. Try changing "post" to "get" to see if that resolves your issue.

I find it strange though that your server would not allow you to send post requests. Do you happen to have a .htaccess file or anything set to disallow POST requests from being sent?
  • Howdy_McGee
  • Novice
  • Novice
  • Howdy_McGee
  • Posts: 16

Post 3+ Months Ago

IDK I talked to the people that owned the server and they told me its a old linux server or something of the sort...

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 48 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.