Forum Moderators: coopster

Message Too Old, No Replies

PHP in a Table

         

bodycount

2:58 pm on Feb 7, 2006 (gmt 0)

10+ Year Member



Can you put PHP code in <TD> </TD> cause this is what i have done and it does not seem to work.
<?php
session_start();
include ("connection.php");

// Register some session variables!
session_register('first_name');
$_SESSION['first_name'] = $first_name;
session_register('last_name');
$_SESSION['last_name'] = $last_name;
session_register('email_address');
$_SESSION['email_address'] = $email_address;
session_register('special_user');
$_SESSION['user_level'] = $user_level;
session_register('username');
$_SESSION['username'] = $username;
?>
<html>
<table> (other table content)
<tr><td>
<?php
if ($username! >0)
{
echo "username";
} else
{
echo "no username";
}

?>
</td></tr>
</table>

All i want to do is. When a person has logged in, it shows there username in that table cell and if they are not a registered user it leaves it blank.

omoutop

3:16 pm on Feb 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi!

instead of
if ($username! >0)

try this
if ($username!= "")

Php can be inerted everywhere, witin tables, input boxes, radio button, titles, textaras and much much more.

Try this and post again

bodycount

4:41 pm on Feb 7, 2006 (gmt 0)

10+ Year Member



That does not seem to work but i think it is something to do with sessions.

After I have logged in I goto to another page which has the following php code

<?
session_start();

echo "". $_SESSION['user_level']."<br> ";
echo "". $_SESSION['username']." <br>";
echo "". $_SESSION['first_name']." <br>";
echo "". $_SESSION['last_name']."<br> ";
echo "". $_SESSION['email_address']."<br> ";
echo "". $_SESSION['info']."<br> ";
echo "". $_SESSION['password']."<br> ";
echo "". $_SESSION['signup_date']."<br> ";
echo "". $_SESSION['last_login']."<br> ";
echo "". $_SESSION['activated']."<br> ";

?>

but the only ones that get displayed even when there is data in all fields is user_level, first_name, last_name, and email_address. so if username is not being displayed then my other post above will not work. Has any one got any ideas why some variables are not displaying?

omoutop

6:25 pm on Feb 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You are passing too many variables as sessions, I can not know for sure if this is the problem but try to cut -off some less important variables and try again

so you can check username by

try this
if ($_SESSION['username']!= "")

eeek

10:42 pm on Feb 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why are you calling session_register and using $_SESSION. You don't need both.