PDA

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


CoolMike
06 Nov 2001, 15:25
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
06 Nov 2001, 23:51
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>";
}
?>