Page 1 of 1

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

Posted: Mon Dec 04, 2006 4:38 pm
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?

Posted: Mon Dec 04, 2006 5:00 pm
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>

Posted: Mon Dec 04, 2006 5:52 pm
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();

Posted: Mon Dec 04, 2006 5:57 pm
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.

ok

Posted: Mon Dec 04, 2006 7:00 pm
by Mythic Fr0st
Thanks guys

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

Posted: Mon Dec 04, 2006 7:04 pm
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?