ferassh
asked on
Posting PHP_AUTH_USER & PHP_AUTH_PW
Hi 2U ALL
I've a page with a basic authentication , I need to access it from PHP page without getting the username-password dialog, I've Treid the following but I'm still getting the dialog requiring the username and passowrd again, so how can I post the username and password through my PHP page?
$PHP_AUTH_USER='testuser';
$PHP_AUTH_PW='testpass';
header("location: /$pathToAuthenticationPage ");
but still getting the dialog although the username and passord are correct for sure.
thanks in advance
FERAS
BYE
I've a page with a basic authentication , I need to access it from PHP page without getting the username-password dialog, I've Treid the following but I'm still getting the dialog requiring the username and passowrd again, so how can I post the username and password through my PHP page?
$PHP_AUTH_USER='testuser';
$PHP_AUTH_PW='testpass';
header("location: /$pathToAuthenticationPage
but still getting the dialog although the username and passord are correct for sure.
thanks in advance
FERAS
BYE
that would work
or you could go
youruser:yourpass@yoursite .com/path- to-file-he re
it works just as simply, if your say including or requiring the file.
-XeRnOuS
or you could go
youruser:yourpass@yoursite
it works just as simply, if your say including or requiring the file.
-XeRnOuS
ASKER
Hi
I read your comment xernous but how can I use it in my php file,
I tried this but it didn't work:
include('name:pass@site.co m/page.php ');
I got no such file or directory error.
I think that I still need a little help ,
Thanks
I read your comment xernous but how can I use it in my php file,
I tried this but it didn't work:
include('name:pass@site.co
I got no such file or directory error.
I think that I still need a little help ,
Thanks
I have to say again that I really don't think there is any way to bypass the login dialog if you want to use HTTP authentication.
HTTP authentication is actually pretty strong and was designed not to be able to be circumvented as easily as you are trying to do. If you are that keen to avoid the login box, you will have to implement some more advanced login mechanism, such as using PHP to handle everything.
This tutorial at devshed (http://www.devshed.com/c/a/PHP/User-Authentication-With-Apache-And-PHP/) was what got me started with putting together a PHP auth system, maybe it'll be good enough for you...
_Blue
HTTP authentication is actually pretty strong and was designed not to be able to be circumvented as easily as you are trying to do. If you are that keen to avoid the login box, you will have to implement some more advanced login mechanism, such as using PHP to handle everything.
This tutorial at devshed (http://www.devshed.com/c/a/PHP/User-Authentication-With-Apache-And-PHP/) was what got me started with putting together a PHP auth system, maybe it'll be good enough for you...
_Blue
ASKER
Hi again
At first thanks 2 u all, but I still haven't got what I want.
Is there any way to pass the username and password to this authentication dialog?
I don't want to bypass it or disable it, I just want to access using my php page without the user intervention.
Feras,
At first thanks 2 u all, but I still haven't got what I want.
Is there any way to pass the username and password to this authentication dialog?
I don't want to bypass it or disable it, I just want to access using my php page without the user intervention.
Feras,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I tried to find a solution to bypass a dialog box with javascript with this script:
<script language="javascript">
function doRequest()
{
var url = "http://www.site.net/members/";
var xmlHttp;
try
{
netscape.security.Privileg eManager.e nablePrivi lege("Univ ersalBrows erRead");
xmlHttp = new XMLHttpRequest();
}
catch (e)
{
xmlHttp = new ActiveXObject("Msxml2.XMLH TTP");
}
xmlHttp.open("GET", url, false, "user", "pass");
xmlHttp.send(null);
xmlHttp = null;
location.replace(url);
}
window.onload = doRequest;
</script>
It must normally work with IE and Mozilla, it worked with some people that it tested it for me. I don't know why, but when I test this script on my computer, I have an error in both IE and Mozilla (Permission denied to call method XMLHttpRequest.open). If someone knows what's wrong, I think it's a good alternative of http://user:pass@domain.com.
It can also be included in a php script.
Régis
<script language="javascript">
function doRequest()
{
var url = "http://www.site.net/members/";
var xmlHttp;
try
{
netscape.security.Privileg
xmlHttp = new XMLHttpRequest();
}
catch (e)
{
xmlHttp = new ActiveXObject("Msxml2.XMLH
}
xmlHttp.open("GET", url, false, "user", "pass");
xmlHttp.send(null);
xmlHttp = null;
location.replace(url);
}
window.onload = doRequest;
</script>
It must normally work with IE and Mozilla, it worked with some people that it tested it for me. I don't know why, but when I test this script on my computer, I have an error in both IE and Mozilla (Permission denied to call method XMLHttpRequest.open). If someone knows what's wrong, I think it's a good alternative of http://user:pass@domain.com.
It can also be included in a php script.
Régis
The $PHP_AUTH_USER and $PHP_AUTH_PW variables (also available through $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PW']) are set by the server every time the page is loaded up.
_Blue