PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old September 30th, 2004, 12:30 PM
Dhruv Dhruv is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 3 Dhruv User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Login/Session script

Hi

I've started making a guestbook and want to add an admin CP. Here is the relavent code.


PHP Code:
function Show_Content()
{
 
session_start();
 print 
"<html>
 <head><title>Guestbook Administration </title></head>
  <frameset cols='185, *' frameborder='no' border='0' framespacing='0'>
      <frame name='menu' noresize scrolling='auto' src='?CODE=02&act=menu'>
       <frame name='body' noresize scrolling='auto' src='?CODE=02&act=$index>
      </frameset>
     </html>"
;
 
}
function 
Show_Pages()
{
 global 
$act$CODE;
 
session_start();
 
$choice = array
 (
    
"idx"   => "idx",
    
"menu"   => "menu"
 
);
 if (
$choice[$_GET['act']] == 'idx' || $_GET['act'] == 'index')
 {
  
Display_Content();
 }
 else if (
$choice[$_GET['act']] == "menu")
 {
  
Admin_Menu();
 }
 else
 {
  print 
"why the heck is this here??";
  
Do_Login();
 }
 



OK, Before i ask the questions, let me just say this. Display_Content(), Admin_Menu() have just 2 lines
session_start();
and print statement
(for now).

As you can see, Show_Content() is called once the login has passed, the Show_Content() calls a framed page. Since i dont want to load pages as such (i want to load functions in the frames) I use the ?CODE=02&act=menu/index
At the top of the script is a switch statement which basically calls Show_Pages() when it reads 02 from the URL. Using the 2nd query, the right function is shown.

All this works so far. Except for a hitch. Even though i dont login, i can directly access the URLs ...CODE=02&act=menu

Obviously this is not right. How do i make sure that the URL can't be accessed unless the session is active? I'm not using cookies and its kinda getting confused. How do i verify EACH time the user clicks on the link that he is who he says he is?

I've not posted the login code because i don want to confuse anyone. But If you think it'd help i'll post it.
Thanks

Reply With Quote
  #2  
Old September 30th, 2004, 05:55 PM
xlordt xlordt is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: 127.0.0.1
Posts: 20 xlordt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 39 sec
Reputation Power: 0
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt
where are you getting the login info from? what i usualy do is, i get the info from the database, then i use something like
PHP Code:
if( $field['user_pass'] == $_POST['passwd' )
{
     
$_SESSION['admin'] = true;
     
$_SESSION['admin_name = $field['admin_name'];



then on the other script i would do something like
PHP Code:
if( !$_SESSION['admin'] == true )
{
    print 
'Admins Only!';
    exit;


there are sorts of ways you can do this, but this is one of the most common way

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Login/Session script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway