"1lt John W. Holmes" schrieb:

> > I'm trying to set up a password section on my website. But I don't want
> > a window popping up asking for a username and password. I'd rather like
> > to have a form that submits the data. I did that and it works fine, but
> > the browser seems to not save the username and password, because if i
> > click on any link, it returns an "unauthorized message"... any ideas?
> > thnx,
>
> Show some code... the possibilities are endless for what you're doing wrong.
>
> ---John Holmes...

ok, here's the code:

the form submits the user name and password in the variables $user and $pw to
another site, which includes this:

if(isset($user) && isset($pw)){
$user = ucwords(strtolower($user));
$PHP_AUTH_USER = $user;
$PHP_AUTH_PW = $pw;}

if(isset($PHP_AUTH_USER)){
$result = mysql_query("select * from _users where user = '$PHP_AUTH_USER'");
$_user = mysql_fetch_array($result);}

if(!isset($PHP_AUTH_USER)) {
header('HTTP/1.0 401 Unauthorized');
echo('unauthorized');
exit;}
else{
$result = mysql_query("select * from _users where user = '$PHP_AUTH_USER'") or
die('Error occured while connecting to database');
$rows = mysql_num_rows($result);
if($rows == 0){
header('HTTP/1.0 401 Unauthorized');
echo"<script>window.location.href='../index.php?action=user_wrong'</script>";
exit;}
else{
$daten = mysql_fetch_array($result);
if($PHP_AUTH_PW == $daten['pw']){
// authorized
}
else{
header('HTTP/1.0 401 Unauthorized');
echo"<script>window.location.href='../index.php?action=pw_wrong&user=$user'</script>";

exit;}}}

And this works fine for just this page. Whenever I click on a link to a page
which includes the same file though, it echoes 'unauthorized'...
Olli


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to