Jump to content

Recommended Posts

I am very new to php and just learning from books.

I create a php with a submit value=Go. and out side of the isset($_POST['submit']) I have a hyperlink that out a with target="_Blank". The problem is when the php is loaded the first time and after submit when I click on the hyperlink I will get an saying something like

Method not supported

submit=GoGet to /dir/abc.html HTML 1.1

 

Seem like some how the submit=Go is added to the Get.

If I go back the the php page and click on the same link again, it will open the page.

 

I noticed when opening a simple html for a php with form method post, I would get a Get method not supported error.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/181727-method-not-supported-error/
Share on other sites

Here is the code:

<?php

if(!$_POST) {

  echo "

  <html>

  <body>

  <form method=\"POST\" action=\"".$_SERVER["PHP_SELF"]."\">

  <input type=\"text\" name\"first\" />

  <br/>

  <input type=\"submit\" name=\"submit\" value=\"Go\" />

  </form>

  </body>

  </html>";

} else {

  $name = $_POST['first'];

  print("Your name is: $name <br/>");

  print('<a href=welcome.html>Home</a>');

  }

?>

This is the error:

Method Not Implemented

=freak&submit=GoGET to /welcome.html not supported.

 

Invalid method in request =freak&submit=GoGET /welcome.html HTTP/1.1

 

Apache/1.3.33 Server at www.johnleeconsulting.info Port 80

 

Also I entered freak on the input box but it is not printed with the print statement, how come?

If I go back and click the link again the welcome.html will open.

 

Thanks.

thanks permiso. Input is printing now but I still have the link issue.

When I click Home this is what I got

 

Method Not Implemented

first=thanks&submit=GoGET to /welcome.html not supported.

 

Invalid method in request first=thanks&submit=GoGET /welcome.html HTTP/1.1

 

Apache/1.3.33 Server at www.johnleeconsulting.info Port 80

Instead of echoing out the HTML, exit PHP to display it, like so:

 

<?php
if(!isset($_POST['submit'))
{
?>

<html>
   <body>
      <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
         <input type="text" name="first" />
         <br />
         <input type="submit" name="submit" value="Go" />
      </form>
   </body>
</html>

<?php
} //<-- end if
else
{
   $name = $_POST['first'];
   echo "Your name is: $name<br /><a href='welcome.html'>Welcome Home</a>";
}
?>

 

It might make it easier to debug this way.

Still get the same error.

 

Method Not Implemented

first=thanks&submit=GoGET to /welcome.html not supported.

 

Invalid method in request first=thanks&submit=GoGET /welcome.html HTTP/1.1

 

Why and how does input text and submit are added to the GET?

 

Can you show us all your code as it stands now?

<?php

if(!isset($_POST['submit'])) {

// if(!$_POST) {

?>

<!--  echo " -->

  <html>

  <body>

  <form method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?>">

  <input type="text" name="first" />

  <br/>

  <input type="submit" name="submit" value="Go" />

  </form>

  </body>

  </html>

<?php

} else {

  $name = $_POST['first'];

  print("Your name is: $name <br/>");

  print('<a href=welcome.html>Home</a>');

  }

?>

 

looks like any hyperlink created from php will give me the error...

I would change the method="POST" to method="post"; it may not make a difference but I never see anyone use capitalized attribute values like that.

 

Also, it would seem that submitting your form is creating a GET request to welcome.html.

 

Is Apache configured to serve .html files through the PHP processor?

 

Is the file this code resides in actually welcome.html?

Here is the link

http://johnleeconsulting.info/php0001.php

 

type something in the input box then click on Go and you will see the link to Home. Click on the link and you will get the error.  If you go back on the browser and click on the link again, the page will show.

 

Is there a way for php to know if the page is a repost or initial post?  I think I only get the error on initial post.

 

John

I went to your link.

 

I typed something in the box.

 

Then I clicked on the 'view source' thing in IE.

 

This is what I saw:


Your name is: asdf <br/><a href=welcome.html>Home</a></iframe></noscript></object></layer></span></div></table></body></html><!-- adsok -->
<script language='javascript' src='https://a12.alphagodaddy.com/hosting_ads/gd01.js'></script>

 

That is not valid HTML code and likely the cause of your problems.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.