PDA

View Full Version : [PHP Newbe] insert HTML with IF


CoolMike
11-06-2001, 01:25 PM
Hi

I would like to use the chat which my hosting provider is offering with the VB username.

I found out I need to use the following link to use the chat:

http://domain.ch:2084/?nick={$bbuserinfo[username]}&channel=domain.ch

But now, I would like that the link is only displayed for registred user. What do I need to change on the following if I would like to insert it in to the style header?


<?
if {$bbuserinfo[username]} <> "unregistred" {
echo "<TR><TD class=menu colSpan=2 onclick="window.location.href='http://domain.ch:2084/?nick={$bbuserinfo[username]}&channel=domain.ch'" onmouseout="this.style.background='#dedfdf'" onmouseover="this.style.background='#FFFFFF'" width="100%"><A class=menu href="http://domain.ch:2084/?nick={$bbuserinfo[username]}&channel=domain.ch">Chat</A></TD></TR> };
?>



I don't know PHP I was just using some examples, but it's not working...

Thanks for your help.

cu
Mike

Mark Hensler
11-06-2001, 09:51 PM
First off... that's sloppy. Spread things around on several lines; you don't need the whole thing on one line.

Second... you see all those narly colors?? that's because syntax is wrong. You forgot to escape your quotes, and close your echo statement.

Try this:

<?
if {$bbuserinfo[username]} <> "unregistred") {
echo "<TR>";
echo "<TD class=menu colSpan=2 onclick=\"window.location.href='http://domain.ch:2084/?nick={$bbuserinfo[username]}&channel=domain.ch'\" onmouseout=\"this.style.background='#dedfdf'\" onmouseover=\"this.style.background='#FFFFFF'\" width=\"100%\">";
echo "<A class=menu href=\"http://domain.ch:2084/?nick={$bbuserinfo[username]}&channel=domain.ch\">Chat</A>";
echo "</TD>";
echo "</TR>";
}
?>