making it so if your not logged in, you cant see content

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

Post Reply
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

making it so if your not logged in, you cant see content

Post by Mythic Fr0st »

I think I may have posted about this before, but I dunno

my problem is, that when you login you see

a table, with logging in and stuff, however, you also see it if your not being logged in...

How do I have PHP with html? so say like

Code: Select all

<html>
<body>
<head>
</head>
<?php
function user()
{
<table = border='1' etc..>
<tr>
   <td>Blah</td>
</tr>
</table>
}
?>
</body>
</html>
So when my MySQL searches for the username & pw, if they match, it'll call user() otherwise it'll call unregistered()

is that possible?
chris12295
Forum Contributor
Posts: 113
Joined: Sun Jun 09, 2002 10:28 pm
Location: USA
Contact:

Post by chris12295 »

You can try this:

Code: Select all

<html>
<body>
<head>
</head>
<?php
function user()
{
?>
<table = border='1' etc..>
<tr>
   <td>Blah</td>
</tr>
</table>
<?
}
?>
</body>
</html>
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

The above will not work. You can assign it to a variable.

Code: Select all

function user()
{
   $ret = 'html code here';
   return $ret;
}
Then assign the function result to a variable or echo it to the page.

Code: Select all

echo user();
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
chris12295
Forum Contributor
Posts: 113
Joined: Sun Jun 09, 2002 10:28 pm
Location: USA
Contact:

Post by chris12295 »

I tested it and it worked for me. If I call the function the table is produced, if I dont, it is not.
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

ok

Post by Mythic Fr0st »

Thanks guys
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: making it so if your not logged in, you cant see content

Post by RobertGonzalez »

Mythic Fr0st wrote:I think I may have posted about this before, but I dunno
Yes, you did --> viewtopic.php?t=60160

Have you gotten a book yet? Or some other form of tutorial that you can reference as you embark on PHP development?
Post Reply