Jul 7, 2008

Http Authentication

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Http Authentication

moldboy
I have a book called PHP and MySQL for dynamic web sites by Larry Ullman, and it's a very good book which I would recomend to anyone wanting to learn, but I followed a project in this book, not letter by letter, and it won' work.
I wrote this code to create an authentication script that will only work with one user but allow the credientals to be passed from one page to another. So here's the code
CODE

<?PHP

$aut = FALSE;
 
//Check for user variables
if ( (isset($_server['PHP_AUTH_USER']) AND isset($_server['PHP_AUTH_PW'])) ) {
 //Check for correct user and password
 $user = $_server['PHP_AUTH_USER'];
 $pw = $_server['PHP_AUTH_PW'];
 
 if ($user == "user" AND $pw == "password"){
   $aut = TRUE;
 }
}

//IF not authorized ask for authentication
if ($aut == FALSE){
 header('WWW-Authenticate: Basic realm="d-gression HTML editor"');
 header('HTTP/1.0 401 Unauthorized'); //If cancel is pressed
}
?>

and the actual page the require points to the above code
CODE
<?PHP
require('./auth.inc');
if ($aut == FALSE){
 echo "please <a href=\"index.php\">try again.</a>";
} else {
 echo "you're in!!!";
}
?>

 

 

 


Reply

moldboy
Well after a nights sleep I figured it out, the part where it says $_server should be $_SERVER

Reply

BuffaloHELP
Topic closed as reported.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : http authentication

  1. Http_redirect() [resolved] - (4)
  2. Mysql Authentication Problems - (11)
    I installed the new version of both php and mysql on my computer and I am trying to work on a
    database. The problem is the following. Even though I have the latest version of both php and mysql,
    and I have created users in the new mysql version, I still get the problem that I get an error
    message about authentication problems. I have no clue what I am doing wrong. It did work for a short
    period of time, but somehow it is no longer working. Is there anyone who has a tutorial on how to
    install both php and mysql? I have the feeling that there are a lot of settings in my.in...
  3. Problem With $http_post_vars - (3)
    I have a piece of code on one server that works and the same piece of code on another server does
    not. The difference is in the PHP verison & the Linux verison The one that works runs PHP4 on Redhat
    Linux. The one that doesn't runs PHP5 on SUSE Linux. Not sure if this is where the issue lies or
    not. I do know that in one case I see an adrress in searchable and in the other case it is null.
    PHP Code: CODE if ($HTTP_POST_VARS[addr]) {     $searchable =
    $HTTP_POST_VARS[addr];     echo "searchable = ".var_dump(...
  4. Http Authentication Without Using The Popup - (3)
    As it is mentioned earlier on in this form I am trying to use HTTP authentication to add simple
    users control to my site, one thing I like about it is that the username and password are stored
    throught the entire session that way I don't have to enter into the realm of cookeis and session
    id's. So now I was wondering, a) can I use a standard html forum and place the password and
    username values into $_SERVER and $_SERVER so that they will be reembered throuout the
    session, and /cool.gif' border='0' style='vertical-align:middle' alt='cool.gif' /> ...
  5. Need Help...again............ - Authentication -_- (5)
    Ok, vizskywalker was finally able to solve the problem with my registration, but when I tried to
    login with my testaccount, it just continuously give me the "wrong username/password" error, i
    registered a new account and tried again, but still fails... here's the authentication page...:
    CODE <?php $user = $_POST['username']; $pass =
    $_POST['password']; $user=strip_tags($user);
    $pass=strip_tags($pass); $user=str_replace("
    ","",$user); ...
  6. Ftp Script Problems - Authentication Failure - (3)
    I uploaded the code as a text file because it's pretty big: http://beeseven.trap17.com/ftp.txt
    As I said it can't login. I get this error: Warning : ftp_login(): Authentication failed,
    sorry in /home/beeseven/public_html/ftp.php on line 45 I think it might have something to do
    with character encoding, but I'm not sure. If you think it is, what kind of encoding would work
    as if I typed it directly? I tried putting it in the file, but then I got the missing required
    fields error....



Looking for http, authentication

Searching Video's for http, authentication
advertisement



Http Authentication



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE