Home › Forum Archive › PC Discussion › PC Game Discussion › PHP Website authentication
- This topic has 6 replies, 3 voices, and was last updated 17 years, 3 months ago by
MasterP.
-
AuthorPosts
-
July 22, 2009 at 2:33 pm #7833
yousillyGoose
SpectatorHey hey. I am playing around with an upload feature on my website (so that I can upload a file from anywhere without having to ftp with filezilla or something fun like that). The upload feature works fine. I want to now password the page where you upload files (so random people can’t access it). I know how to use .htaccess and all that, but I do not want an entire directory passworded- just the one page.
This works on one server but not another because the second server is in cgi-php mode:
if ((!isset($PHP_AUTH_USER)) || (!isset($PHP_AUTH_PW))) { /* No values: send headers causing dialog box to appear */ header('WWW-Authenticate: Basic realm="My Private Stuff"'); header('HTTP/1.0 401 Unauthorized'); echo 'Authorization Required.'; exit; } else if ((isset($PHP_AUTH_USER)) && (isset($PHP_AUTH_PW))){ /* Values contain some values, so check to see if they're correct */ if (($PHP_AUTH_USER != "user") || ($PHP_AUTH_PW != "password")) { /* If either the username entered is incorrect, or the password entered is incorrect, send the headers causing dialog box to appear */ header('WWW-Authenticate: Basic realm="My Private Stuff"'); header('HTTP/1.0 401 Unauthorized'); echo 'Authorization Required.'; exit; } else if (($PHP_AUTH_USER == "user") || ($PHP_AUTH_PW == "password")) { /* if both values are correct, print success message */ echo "<P>You're authorized!</p>"; } } ?>Do you have any idea how to make this work under cgi? I read and attempted:
http://www.francey.org/articles/http-authe…on-php-cgi.html
but it didn’t work (though I’m an idiot and may have been trying it wrong).
Any help is appreciated.
PS.
I’m a TOTAL php noob so don’t assume I know anything in your response!
Rob
July 22, 2009 at 2:40 pm #88911MasterP
SpectatorWindows or Linux box and do you have Cpanel installed?
July 22, 2009 at 2:59 pm #88913yousillyGoose
SpectatorIt is a dreamhoster server (not my own personal one). And it is a linux box
.July 22, 2009 at 3:21 pm #88915MasterP
SpectatorMasterP said:
do you have Cpanel installed?July 22, 2009 at 4:03 pm #88917yousillyGoose
SpectatorHeh, what is cpanel?
I have the panel.dreamhoster….. stuff I can access it with. Is that cpanel?
July 23, 2009 at 9:56 pm #88973Derrick LeBrocq
SpectatoryousillyGoose said:
Heh, what is cpanel?And some shlub on the internet allows YOU do have a server?
Blasphemy….
July 23, 2009 at 10:11 pm #88975MasterP
SpectatorIf you have a linux box I highly recommend you use it.
-
AuthorPosts
- The forum ‘PC Game Discussion’ is closed to new topics and replies.