A really big problem! :(

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Think-Digitally
Forum Commoner
Posts: 25
Joined: Wed Feb 04, 2004 2:25 pm

Post by Think-Digitally »

Great thanks malcolmboston.

I suppose you couldnt know about the initial questions would you?
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

lol sorry im tired, what were the Q's?
Think-Digitally
Forum Commoner
Posts: 25
Joined: Wed Feb 04, 2004 2:25 pm

Post by Think-Digitally »

I have a script already done, it all works... but I cant get the login to make sure that the viewer is logged in, otherwise they can just type in the URL and no need to join.

Maybe I was writting it wrong. this is how I did it, and you can tell me what the hell I am doing wrong!!

I have made a new file called context.php and put this in it;

<?

function session_checker(){
if(!session_is_registered('first_name')){
include 'loginform.htm';
exit();
}
}

?>

exactly like that on its own in that file.

In the html document that I want to protect from viewers that are not logged in I have put this at the top before the <html> tag.

<?php

include 'context.php';

session_start();
session_checker();

?>

Is that completely wrong??
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

just cleaning it up; 2 mins

Code: Select all

<? 

function session_checker(){ 
if(!session_is_registered('first_name')){ 
include 'loginform.htm'; 
exit(); 
} 
} 

?> 

exactly like that on its own in that file. 

In the html document that I want to protect from viewers that are not logged in I have put this at the top before the <html> tag. 

<?php 

include 'context.php'; 

session_start(); 
session_checker(); 

?>
Think-Digitally
Forum Commoner
Posts: 25
Joined: Wed Feb 04, 2004 2:25 pm

Post by Think-Digitally »

Okay, thanks :)
Post Reply