4 Replies - 540 Views - Last Post: 20 December 2012 - 04:18 AM Rate Topic: -----

#1 theborg72  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 05-May 10

show if user login

Posted 19 December 2012 - 03:34 PM

I'm trying to make a function that displays content depending on whether you are logged in or not.
have both pulled hair and looked around .. the closest I found is.

<?php
if ($_SESSION['Admin'] == true) {
?>
<p>you are login</p>
<?php
} else {
?>
<p>ju are not login</p>
<?php
}
?>



but I can not get it to work as I after looking fore
This is how the page look like now

?php include($_SERVER['DOCUMENT_ROOT'].'/Connections/PhPdev.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Namnlöst dokument</title>
</head>

<body>
<?php
if ($_SESSION['isAdmin'] == true) {
?>
<p>My admin html</p>
<?php
} else {
?>
<p>My non-admin html</p>
<?php
}
?>
</body>
</html>




but I can not understand how I can get the fuktionen to work.

Is This A Good Question/Topic? 0
  • +

Replies To: show if user login

#2 Sho Ke  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 110
  • View blog
  • Posts: 250
  • Joined: 13-October 11

Re: show if user login

Posted 19 December 2012 - 04:13 PM

Are you getting any errors? In the code you posted, you didn't even start the session, so the code you posted should be throwing an error unless you either (1) have error handling disabled or (2) call session_start() in PhPdev.php.

Can you post the code from PhPdev.php?
Was This Post Helpful? 0
  • +
  • -

#3 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 928
  • View blog
  • Posts: 3,212
  • Joined: 19-January 10

Re: show if user login

Posted 19 December 2012 - 04:26 PM

I would suggest you try learning PHP first. You can't just go around copy and pasting snippets you find off the internet.
Was This Post Helpful? 0
  • +
  • -

#4 theborg72  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 05-May 10

Re: show if user login

Posted 20 December 2012 - 02:58 AM

View PostSho Ke, on 19 December 2012 - 04:13 PM, said:

Are you getting any errors? In the code you posted, you didn't even start the session, so the code you posted should be throwing an error unless you either (1) have error handling disabled or (2) call session_start() in PhPdev.php.

Can you post the code from PhPdev.php?


<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"

$hostname_PhPdev = "localhost";
$database_PhPdev = "phpdev";
$username_PhPdev = "username";
$password_PhPdev = "passwork";
mysql_query("SET NAMES 'utf8'", $connection);
$PhPdev = mysql_pconnect($hostname_PhPdev, $username_PhPdev, $password_PhPdev) or trigger_error(mysql_error(),E_USER_ERROR); 
mysql_query("SET NAMES 'utf8'") or die(mysql_error());
mysql_query("SET CHARACTER SET 'utf8'") or die(mysql_error()); 
?>


Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6110
  • View blog
  • Posts: 23,667
  • Joined: 23-August 08

Re: show if user login

Posted 20 December 2012 - 04:18 AM

I know you don't like the answer, but I suspect creativecoding nailed it. Where do you set the Admin and/or isAdmin SESSION variable, for example? DO you realize those are two different variables?
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1