dj-kenpo Posted March 27, 2007 Share Posted March 27, 2007 Hi all, you know the apache built in authenticate boxes? username+password. is it possible to run a php script that can log into that? do I send the username/pass as a post? is this possible? I've searched everywhere and only found info on making one. I don't want to make one, I want to log into one via a php script. reason: dreamhost uses that for the login for the stats page, I want to read the data from the page in a php script, but first I need to log in.... thanks for any help Quote Link to comment Share on other sites More sharing options...
simcoweb Posted March 27, 2007 Share Posted March 27, 2007 You're better off using a database method of login instead of the .htaccess Apache method. That way you use a nice looking login form instead of that ugly gray box. Quote Link to comment Share on other sites More sharing options...
dj-kenpo Posted March 27, 2007 Author Share Posted March 27, 2007 I realize that, but as I said, this is a built in application to my webhost. I cannot remove the ugly grey box. Quote Link to comment Share on other sites More sharing options...
simcoweb Posted March 27, 2007 Share Posted March 27, 2007 In that case, having a PHP login script is pointless. In other words, it doesn't accomplish anything because all it would do is pull up the same ugly gray box. If that's the method they use then not much you can do with it. Quote Link to comment Share on other sites More sharing options...
dj-kenpo Posted March 27, 2007 Author Share Posted March 27, 2007 No, what I'm asking is if there's a way to send the login information via the headers or a post and skip the grey box via an automated login script. Quote Link to comment Share on other sites More sharing options...
dj-kenpo Posted March 28, 2007 Author Share Posted March 28, 2007 anyone? the only thing I found was http://username:password@www.domain.com/dir but with $content=file_get_contents("http://username:password@www.domain.com/dir",FALSE,NULL,0,200); that simply returns "failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required". Quote Link to comment Share on other sites More sharing options...
dsaba Posted March 28, 2007 Share Posted March 28, 2007 ok here's the deal: a user/login page is indeed a form only way to make a form work, and to post variables to a form process page is to have a HUMAN fill out or press teh submit button HOWEVER you can use the curl library in php and curl functions to use php to submit form variables directlyt to the form processing script research curl functions in php.net, thats how you can POST to a form without actually filling out or pressin teh submit button, a php script can do this Quote Link to comment Share on other sites More sharing options...
dj-kenpo Posted March 29, 2007 Author Share Posted March 29, 2007 Thanks Dsaba! the cURL libarary was EXACTLY what I needed and it worked perfectly! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.