SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2007
    Location
    Twin Cities, Minnesota, USA
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    HTTP 405 from index.php in BYO DBD Web Site

    Am new to PHP and working through K Yank's PHP/MySQL book. I'm using PHP 5.2.11 and IIS 5 - PHP pages are working fine until this behavior I don't understand, around page 100, 4th edition.

    I've put the source under the document base in directory chapter3/welcome - there are 3 files, index.php, welcome.html.php, and form.html.php - when I use the URL suggested in the chapter - it does not include index.php - then, when I click on the submit, it gives me "HTTP 405 - Resource not allowed" from IIS - top of the page says "The page cannot be displayed" - I can't put the URL here, as I've not had enough posts yet!

    If I use a URL with index.php at the end, it works fine.

    Is this an oddity of IIS 5? Would Apache do it right?

    At any rate, I can keep going, so long as I include the full URL.

    Code is listed here for index.php

    Code PHP:
    <?php
    if (!isset($_POST['firstname']))
    {
     include 'form.html.php';
    }
    else
    {
     $firstname = $_POST['firstname'];
     $lastname = $_POST['lastname'];
     if ($firstname == 'Kevin' and $lastname == 'Yank')
     {
      $output = 'Welcome, oh glorious leader!';
     }
     else
     {
      $output = 'Welcome to our web site, ' .
        htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8') . ' ' .
        htmlspecialchars($lastname, ENT_QUOTES, 'UTF-8') . '!';
     }
     include 'welcome.html.php';
    }
    ?>

    Thanks for your help
    Vern

  2. #2
    SitePoint Addict
    Join Date
    Jan 2007
    Posts
    344
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You may not have IIS configured to allow index.php as a default page. Look in the management console under application configruation in the home directory tab. It will usually list default.htm, default.html, default.asp, index.asp, index.htm, index.html as allowed default pages. Add index.php or default.php according to your needs and tastes.

    amazon.com and target.com will cause a 405 when used as the input on the test at newsreports.org because they refuse HEAD requests. Are you perhaps configured the same way? That is settable in the console as well.

  3. #3
    SitePoint Member
    Join Date
    Oct 2007
    Location
    Twin Cities, Minnesota, USA
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi plumsauce

    Actually I do have index.php as one of the default pages. I think that is why the page displays just fine when I don't specify it in the URL. The problem comes when I click on the submit button of the form - then it puts up the error. If I have put index.php in the URL, it all works.

    I don't know about the HEAD thing - my IIS is pretty vanilla, except for the addition now of index.php in the list of default pages.

    Is there maybe some issue about the path for includes? Does IIS not know where it is when you don't include the actual file name in the URL?

    Thx again

  4. #4
    SitePoint Member
    Join Date
    Oct 2007
    Location
    Twin Cities, Minnesota, USA
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just did what I should have done longer - dug around with Google - and got a link to Microsoft's knowledge base that is entitled: 'BUG: You may receive an HTTP 405 "Method not allowed" error message when you browse the default document without specifying the file name'. The former KB number was Q216493.

    Apparently this happens with a POST - a GET is supposed to work, but the point of this was to hide the URL query data. This was a bug in IIS 4 and IIS 5 and fixed in IIS 6.

    I don't know whether I can get IIS 6 for XP Pro - I'll probably install Apache after all. I stayed with IIS because that is used for a community band website I manage - using classic ASP that I changed from the original pretty clunky code.

    Thx much and hope this is useful to others.
    Vern


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •