You are here: Re: Login / Password « PHP Programming Language « IT news, forums, messages
Re: Login / Password

Posted by FP on 07/18/06 04:34

Rik wrote:
> FP wrote:
> > I want to put some code at the top of my pages which will prompt the
> > user for a name & password if the session variable IDUser is not set.
> >
> > How do I get the browser to display the login / password dialog and
> > how do I access the data the user entered.
>
> http://www.php.net/manual/en/features.http-auth.php
>
> Grtz,
> --
> Rik Wasmus


I had a look at the manual and it's clear as mud.
Tomorrow I'm going to try to put the following code in an include and
call it from the different pages; it's currently working with 1 page.
If anyone sees potential problems with it, could you please point them
out.

if ($_SESSION['IDUser']=='') {
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="Demo"');
header('HTTP/1.0 401 Unauthorized');
exit;
}
//connect to database searching for record where
Login = $_SERVER['PHP_AUTH_USER'];
Pwd = $_SERVER['PHP_AUTH_PW'];
if(no records found){
header('WWW-Authenticate: Basic realm="Demo"');
header('HTTP/1.0 401 Unauthorized');
}else{
$_SESSION['IDUser'] = database record ID
}
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация