Jump to content

Show Logged In User


tkolbeck

Recommended Posts

Here is the code that I am using:

 

<?

 

session_start();

if(!session_is_registered(myusername)){

 

header("location:index.php");

}

echo "Hello, $username";

?>

 

<html>

<body>

Login Successful

</body>

</html>

 

 

and it doesnt show that it outputs "Hello,Login Successfull"

 

Link to comment
https://forums.phpfreaks.com/topic/40885-show-logged-in-user/#findComment-198007
Share on other sites

Now I am getting this error:

 

Parse error: parse error, unexpected $ in /home/www/bbbshops.com/login_success.php on line 28

 

when there is nothing on line 28

 

Here is my code

 

 


<?php 

session_start();
if(!session_is_registered(myusername)){

header("location:index.php");
}

if(session_is_registered(myusername)){

echo "Hello, ".$_SESSION['myusername']." ";

} else {
echo "Hello Guest"


?>

<html>
<body>
Login Successful
</body>
</html>



Link to comment
https://forums.phpfreaks.com/topic/40885-show-logged-in-user/#findComment-198023
Share on other sites

Hi!

 

Here is the right code:

 

<?php 

session_start();
if(!session_is_registered(myusername)){

header("location:index.php");
}

if(session_is_registered(myusername)){

echo "Hello, ".$_SESSION['myusername']." ";

} else {
echo "Hello Guest"


?>

<html>
<body>
Login Successful
</body>
</html>

<?php
}

 

Do you see your mistake now?

 

 

All the best,

Adika

 

Link to comment
https://forums.phpfreaks.com/topic/40885-show-logged-in-user/#findComment-198109
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.