Total members 11864 |It is currently Thu Dec 09, 2021 5:54 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Using this code you can protect a single page .users have to enter password to view the page .The code check if correct password and username .


Code:

<?php

function checklogin($username, $password){
    if (
            (
                !isset(
$_SERVER['USER_USERNAME']) ||
                (
                    isset(
$_SERVER['USER_USERNAME']) &&
                    
$_SERVER['USER_USERNAME'] != $username
                
)
            ) &&
            (
                !isset(
$_SERVER['USER_PASSWORD']) ||
                (
                    isset(
$_SERVER['USER_PASSWORD']) &&
                    
$_SERVER['USER_PASSWORD'] != $password
                
)
            )
        )
    {
        
header('WWW-Authenticate: Basic realm="Login"');
        
header('HTTP/1.0 401 Unauthorized');
        echo
'Please login first.';
        exit;
    }
}
?>




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Protect page using password in PHP
 php Password protect a page     -  
 How to protect your software     -  
 Image Scroller-scrollbar-LINE_UP,LINE_DOWN-PAGE-UP-PAGE-DOWN     -  
 how to encrypt password in jsp     -  
 generate password using php     -  
 simple password Strength checker     -  
 Input username and password in JAVA     -  
 Password Security Manager Access File Java     -  
 AJAX Login Code getting username and password dynamically .     -  
 Mile200: Removing Username, Password & Login from Header     -  



Topic Tags

PHP Validation






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com