Current location: Hot Scripts Forums » Programming Languages » PHP » Single file security


Single file security

Reply
  #1 (permalink)  
Old 06-28-03, 07:21 AM
PersuT PersuT is offline
New Member
 
Join Date: Jun 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Single file security

i have created a main admin page for all my sites and i want to password protect it, what is the best way to do this.
and i dont want to use a .htaccess file
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-28-03, 07:54 AM
ChristGuy ChristGuy is offline
Operations Support Develo
 
Join Date: Jun 2003
Location: Rivonia, South Africa
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
I'd say using sessions...

Basically...

at the top of protected pages:
PHP Code:

<?php

  
if (!isset($_SESSION["username"]))
  {
    
Header('Location: login.php');
  }
?>
To register the variables:
PHP Code:

<?php

  
// If the user is valid
  
if (IsValidUser($Username))
  {
    
$_SESSION["username"] = $Username;
  }
  else
  {
    echo 
"Invalid user"
  
}
?>
To logout
PHP Code:

<?php

  $_SESSION 
= array();
  
Session_destoy();
?>
Hope that helps...
__________________
Till We Meet Again...
Clifford W. Hansen
Aspivia (Pty) Ltd

"We Have Seen Strange Things Today!" Luke 5:26
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP code to edit a text file mdhall Script Requests 12 12-23-10 05:03 AM
New Web Host, New Problem! justchat PHP 2 09-29-03 03:39 PM
Script to change file extensions JavaHead Script Requests 2 09-13-03 10:44 AM
Writes to a text file gamextremer2003 JavaScript 4 09-11-03 10:43 AM
Upload file type and size limiter! Arctic ASP 1 08-02-03 08:06 PM


All times are GMT -5. The time now is 08:39 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.