Hey php fans,
I was wondering if anyone had difficulty with using http authorization headers while using godaddy as a host provider?
Examples of its usage show that you (the programmer) can code it to a chosen username and password, and the rest is taken care of (in terms of the actual security etc).
However, when I have tried to use it, the username and password I have inputted does not work; instead, it recycles the page looking for the correct information.
Also, it looks to access a folder(?) or server(?) with the name of the account I have with godaddy.
Frankly, I am just looking to see if anyone else has this problem who has a website hosted by godaddy, and if so, what they did to fix it or make it work.
Thanks.
The code:
[php]<?php
$username = ‘alien’;
$password = ‘abduction’;
$auth = 0;
if (!isset($_SERVER[‘PHP_AUTH_USER’]) || !isset($_SERVER[‘PHP_AUTH_PW’]) ||
($_SERVER[‘PHP_AUTH_USER’] != $username) || ($_SERVER[‘PHP_AUTH_PW’] != $password))
{
$auth = 1;
header(‘HTTP/1.1 401 Unauthorized’);
header(‘WWW-Authenticate: Basic realm=“Alien Abduction”’);
exit (‘
Alien Abduction
Sorry, you must enter a valid user name and password to access the Administrators page.’);}
else if ($PHP_AUTH_USER == ‘$username’ && $PHP_AUTH_PW == ‘$passwor’)
{
$auth != 1;
echo ‘
You are authorized!
’;}
?>[/php]