Go Back   CodingForums.com > :: Server side development > PHP > Post a PHP snippet

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-26-2012, 04:41 AM   PM User | #1
Hydrian
New Coder

 
Join Date: Aug 2012
Posts: 40
Thanks: 5
Thanked 0 Times in 0 Posts
Hydrian is an unknown quantity at this point
Login echo array

I have this in my website using it in my chat. I recommend it if you have a login system. and need to see if a user is or isnt logged in

PHP Code:
<?php
session_start
();
include_once
"config.php";
if(!isset(
$_SESSION['username']) || !isset($_SESSION['password'])){
         echo 
'<h4>You are not logged in. Please do so <a href="http://jays.netne.net/loginsystem/login.php">Login</a></h4>'; }


        else {
            echo 
"<h4>You are logged in </h4>";
        }
?>
Hydrian is offline   Reply With Quote
Old 08-26-2012, 05:37 AM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
The problem with this though is you will echo out text before any DOCTYPE in your HTML because a session_start() needs to be called be any headers. It might be better to just setup a string with the message and then print it out later in the body of your HTML.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:52 AM.


Advertisement
Log in to turn off these ads.