note 9288 modified in features.http-auth by irc-html

From: Date: Sat, 19 Jan 2002 20:27:03 +0000
Subject: note 9288 modified in features.http-auth by irc-html
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-25306@lists.php.net to get a copy of this message
Just a little snippet to help people that want to have EASY/SIMPLE/NONSECURE authentication that looks "official" ////////////////////////// USED FOR AUTHENTICATION //////////////////////// function authenticate_user(){ Header("WWW-Authenticate: Basic realm=\"Restricted Admin Area\""); Header("HTTP/1.0 401 Unauthorized"); echo "You are not authorized to enter this section of the site!\n"; exit; } if(!isset($PHP_AUTH_USER)) { authenticate_user(); } else { $sql = "SELECT * FROM admins WHERE adminUsername='$PHP_AUTH_USER' && adminPassword='$PHP_AUTH_PW'"; $r = mysql_query($sql); if(@mysql_num_rows($r) < 1){ authenticate_user(); } } ////////////////////////// USED FOR AUTHENTICATION //////////////////////// http://www.miester.org --was-- Just a little snippet to help people that want to have EASY/SIMPLE/NONSECURE authentication that looks "official" <pre> ////////////////////////// USED FOR AUTHENTICATION //////////////////////// function authenticate_user(){ Header("WWW-Authenticate: Basic realm=\"Restricted Admin Area\""); Header("HTTP/1.0 401 Unauthorized"); echo "You are not authorized to enter this section of the site!\n"; exit; } if(!isset($PHP_AUTH_USER)) { authenticate_user(); } else { $sql = "SELECT * FROM admins WHERE adminUsername='$PHP_AUTH_USER' && adminPassword='$PHP_AUTH_PW'"; $r = mysql_query($sql); if(@mysql_num_rows($r) < 1){ authenticate_user(); } } ////////////////////////// USED FOR AUTHENTICATION //////////////////////// </pre> http://www.miester.org http://www.php.net/manual/en/features.http-auth.php

« previous php.notes (#25306) next »