Go Back   Dreamweaver Club Forums > Hand Coders Forum > General
Register FAQ Members List Search Today's Posts Mark Forums Read

Thread Tools Display Modes
Old 08-18-2007, 09:08 PM   #1
Join Date: Aug 2007
Posts: 3
Talking PHP login script tutorial

First i would like to say that the php tutorials are excellent they have helped me learn and understand a lot about php but i seem to be having a bit of trouble with sessions. i have a members panel that i would like to link to other php pages but the code

header ("location:loginpage.php");

does not work properly for all the pages when i try to use it in an include or just add it to the new page it gives me a mysql error that the headers have already been set is there some way i need to change or edit this code for the session to continue through to the linked pages? Any help would be fantanstic. Sorry im such a nub lol.
Piro is offline   Reply With Quote
Old 08-19-2007, 02:04 AM   #2
davidj's Avatar
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256

ok you have this...

PHP Code:
if(!isset($_SESSION['id'])){ //<< check the session is empty
header ("location:loginpage.php"); //<< redirect if it is
echo "ACCESS DENIED!!"// << echo a message if it is
exit; // << exit script

how can you redirect to a different page and at the same time echo a message?

also a tip...

never echo within the main PHP and above any HTML. This is why your getting "headers already sent" errors.

best to assign any message within an IF statement to a variable then echo it inside the HTML
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 08-19-2007, 01:31 PM   #3
Join Date: Aug 2007
Posts: 3

ok i took out the echo statement and i still get the same message
Warning: Cannot modify header information - headers already sent by (output started at C:\Documents and Settings\Piro\My Documents\web root\test\rfeditmain.php:2) in C:\Documents and Settings\Piro\My Documents\web root\test\rfeditmain.php on line 7

header ("location:rfloginpage.php");
with that as line 7 ive also tried using session register isntead of start that doesnt work either not sure what i should do to fix this
Piro is offline   Reply With Quote
Old 08-19-2007, 01:43 PM   #4
Join Date: Aug 2007
Posts: 3
Thumbs up

never mind must have been something about the way i coded that page it works fine with some others i tested thnx for the info anyways
Piro is offline   Reply With Quote

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 On
HTML code is Off

Forum Jump

All times are GMT. The time now is 04:54 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com