Hi, I was wondering if there is a way to get what username and password they entered in php so that I could give them a user permission.
dEcade
Get .htaccess username/password
Started by dEcade, Oct 07 2006 04:54 PM
4 replies to this topic
#1
Posted 07 October 2006 - 04:54 PM
#2
Posted 07 October 2006 - 06:48 PM
Not quite sure what you mean by that.
Do you mean like authorization levels that are defined in .htaccess? I wouldn't know much about that, don't quite see how that would be possible honestly.
Maybe you could do something with $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PASS'], what I tend to do for something like that.
Again, not quite sure on this, lol.
Do you mean like authorization levels that are defined in .htaccess? I wouldn't know much about that, don't quite see how that would be possible honestly.
Maybe you could do something with $_SERVER['PHP_AUTH_USER'] and $_SERVER['PHP_AUTH_PASS'], what I tend to do for something like that.
header('WWW-Authenticate: Basic realm="Authorization Required"');
header('HTTP/1.0 401 Unauthorized', false);
$query = mysql_query("SELECT `id` FROM `users` WHERE `username` = '$_SERVER[PHP_AUTH_USER]' AND `password` = '$_SERVER[PHP_AUTH_PW]'") or die(mysql_error());
Again, not quite sure on this, lol.
Edited by Demonslay, 07 October 2006 - 06:48 PM.
#3
Posted 07 October 2006 - 11:07 PM
Well like I would use the page protected in the CPanel but then I want the php to see what was entered in it like if the username was "dEcade" and my password was "something" then it would allow me to edit everything in the admin panel. But if your username was "John" and password "something" it would only allow you to edit a limited amount of things. So basically I was just wondering if there was a way of getting the data that is entered by using something like $_POST or $_GET.
dEcade
dEcade
#4
Posted 09 October 2006 - 11:23 PM
If you want to do something like that it would be best to go demonslays route and not via cPanel/.htaccess. The simple reason for that is because it's easier to update and manage.
If you don't go with his way, you can try checking the $_SERVER variables to see if the info is sent. If not, you're s-o-l (or you're running the CGI version of php which doesn't register those values anyway).
p.s. Make sure you're not confused by the fact that, in the same post, demonslay uses $_SERVER['PHP_AUTH_PASS'] and $_SERVER['PHP_AUTH_PW']. I believe PW is the correct one, you can always check php.net though.
If you don't go with his way, you can try checking the $_SERVER variables to see if the info is sent. If not, you're s-o-l (or you're running the CGI version of php which doesn't register those values anyway).
p.s. Make sure you're not confused by the fact that, in the same post, demonslay uses $_SERVER['PHP_AUTH_PASS'] and $_SERVER['PHP_AUTH_PW']. I believe PW is the correct one, you can always check php.net though.
Edited by rc69, 09 October 2006 - 11:24 PM.
#5
Posted 10 October 2006 - 05:52 PM
Opps, lol, PHP_AUTH_PW is the correct one, as I got that directly form my working script. Don't know why I said 'PHP_AUTH_PASS' lol.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
