Professional Web Applications Themes

Login test before redirect - PHP Development

I'm redirecting users to a url in the format of: http://name:mysite.com members.mysite.com uses htaccess for authentication. I want to test the login url with the specific user's username and password before I redirect them there. I've tried fopen and seem to get different results. Is there any other way possible? maybe curl? Please help. TIA...

  1. #1

    Default Login test before redirect

    I'm redirecting users to a url in the format of:

    http://name:mysite.com

    members.mysite.com uses htaccess for authentication.

    I want to test the login url with the specific user's username and
    password before I redirect them there. I've tried fopen and seem to
    get different results. Is there any other way possible? maybe curl?

    Please help. TIA
    neeper Guest

  2. #2

    Default Re: Login test before redirect

    neeper wrote: 

    Then you would need to test $_SERVER['PHP_AUTH_USER'] and
    $_SERVER['PHP_AUTH_PW'] to verify the credentials.

    When your goal is just to open the URL with the credentials, you should use
    fsockopen to open the connections and send something like the following to
    logon:

    fputs($fp, "Authorization: Basic " . base64_encode("username:password") .
    "\r\n");

    Be aware that the latest service packs on Windows cause errors when using
    this type of URL's in IE.


    JW



    Janwillem Guest

  3. #3

    Default Re: Login test before redirect

    How do I test the remote site if the login works before presenting it
    to the user?

    On Tue, 14 Jun 2005 23:04:09 +0200, "Janwillem Borleffs"
    <com> wrote:
     
    >
    >Then you would need to test $_SERVER['PHP_AUTH_USER'] and
    >$_SERVER['PHP_AUTH_PW'] to verify the credentials.
    >
    >When your goal is just to open the URL with the credentials, you should use
    >fsockopen to open the connections and send something like the following to
    >logon:
    >
    >fputs($fp, "Authorization: Basic " . base64_encode("username:password") .
    >"\r\n");
    >
    >Be aware that the latest service packs on Windows cause errors when using
    >this type of URL's in IE.
    >
    >
    >JW
    >
    >[/ref]

    neeper Guest

  4. #4

    Default Re: Login test before redirect

    neeper wrote:

    Please don't TOP Post!
     

    Quite elementary, Mr. Watson:

    $username = 'username';
    $password = 'password';
    $host = 'host';
    $path = '/';

    $fp = fsockopen($host, 80);
    fputs($fp, "HEAD $path HTTP/1.0\r\n");
    fputs($fp, "Host: $host\r\n");
    fputs($fp, "Authorization: Basic " .
    base64_encode("$username:$password") .
    "\r\n\r\n");

    list(,$response) = explode(" ", fgets($fp, 1024));
    fclose($fp);

    if ($response == 401) {
    // Unauthorized
    }



    JW


    Janwillem Guest

  5. #5

    Default Re: Login test before redirect

    is $response contents of the page, what if the page has a custom error
    message with an image without '401' in html. Will the 401 still be
    caught as a server error message response?









    On Wed, 15 Jun 2005 18:46:06 +0200, Janwillem Borleffs
    <com> wrote:
     
    >
    >Quite elementary, Mr. Watson:
    >
    >$username = 'username';
    >$password = 'password';
    >$host = 'host';
    >$path = '/';
    >
    >$fp = fsockopen($host, 80);
    >fputs($fp, "HEAD $path HTTP/1.0\r\n");
    >fputs($fp, "Host: $host\r\n");
    >fputs($fp, "Authorization: Basic " .
    > base64_encode("$username:$password") .
    > "\r\n\r\n");
    >
    >list(,$response) = explode(" ", fgets($fp, 1024));
    >fclose($fp);
    >
    >if ($response == 401) {
    > // Unauthorized
    >}
    >
    >
    >
    >JW
    >[/ref]

    neeper Guest

  6. #6

    Default Re: Login test before redirect

    neeper wrote:

    A: Because questions are followed by answers
    Q: Why shouldn't I top post?
     

    What you are trying test is HTTP Basic Authentication, which means that
    a 401 header is sent to the browser when the credentials are not
    supplied or incorrect.

    In all other cases, you will get a 200, 301, 302 etcetera as the
    response code.


    JW


    Janwillem Guest

Similar Threads

  1. Question redirect on login
    By Kirkman in forum Brainstorming Area
    Replies: 0
    Last Post: June 27th, 08:47 PM
  2. Login Redirect
    By James Jiao in forum PHP Development
    Replies: 7
    Last Post: September 25th, 08:12 AM
  3. asp.net login contol using url redirect
    By Rico in forum ASP.NET Security
    Replies: 5
    Last Post: July 24th, 12:20 PM
  4. Replies: 6
    Last Post: September 10th, 04:22 AM
  5. User Login to Redirect using PHP
    By SpeedRacer21 webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 3
    Last Post: July 9th, 05:40 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139