Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cause 403 error using PHP

    How to cause 403 error using PHP?

    I used this to create 401 error in members' only Web pages.
    Code:
    <?php
    header('HTTP/1.0 401 Unauthorized');
    ?>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    For 403:
    Code:
    header("HTTP/1.0 403 Forbidden");
    If you have access to .htaccess files, you'd be better off controlling output that way.
    This will mearly create the page, it will not validate for any security (alone that is).

  • #3
    New Coder
    Join Date
    Jun 2011
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question

    Thanks Fou-Lu, but i tried that on my host and it didn't actually work, so any other way? Thanks!!

  • #4
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi.
    I have an authorization required page created with php.
    I want to do this: if the login fails, the page will show the 403 http error.
    How to use php to show 403 http error page?
    the code:
    header('HTTP/1.1 403 Forbidden');
    does not work.
    Is it possible to use "Include" to show the error 403?

  • #5
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I did this :
    a file with name: 403.php:
    Code:
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html><head>
    <title>403 Forbidden</title>
    </head><body>
    <h1>Forbidden</h1>
    <p>You don't have permission to access <?php
    echo $_SERVER['SCRIPT_NAME'];
     ?> on this server.</p>
    <p>Additionally, a 403 Forbidden
    error was encountered while trying to use an ErrorDocument to handle the request.</p>
    </body></html>
    and an "include" like this:
    Code:
    include('403.php');
    exit;


  •  

    LinkBacks (?)


    Posting Permissions

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