Announcement

Collapse
No announcement yet.

Can I put php code in header?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can I put php code in header?

    Hi. I want my forum title image to rotate everytime be refreshed.
    So I tried to put some php code that can rotate images in header, but it doesn't work.

    this is what i inserted,

    <?php
    $random = round( (double)microtime() * 2);
    if($random<=0) $random=1;
    if($random>2) $random=2;
    echo "<img src=images/title/$random.gif height=100 width=230>";

    ?>


    Any idea?

  • #2
    1) Make sure parse header as PHP is turned on.
    2) You don't need the <?php ?> tags
    3) Don't echo() it, set the header variable:

    Code:
    $random = round( (double)microtime() * 2); 
    if($random<=0) $random=1; 
    if($random>2) $random=2; 
    $header = "<img src=images/title/$random.gif height=100 width=230>";
    Put that in and make sure header as PHP code is on

    Comment


    • #3
      It didn&#039;t work...

      Thanks for your reply.
      As you said, I put code without <?php and echo, but it didn't work.
      When I saw the source of that page, there wasn't $random and $header.
      I think the page cannot recognize the word with $.
      Please give me a another way.
      Thanks.

      [Edited by im2000dbz on 11-01-2000 at 12:30 PM]

      Comment


      • #4
        Here is my header template;


        echo "<table width=100%>";
        echo "<tr>";
        echo "<td valign=middle align=center bgcolor=#FFFFFF>";
        echo "<a href=index.php><img src=/forums/images/mcpa.gif border=0></a>";
        echo "</td>";
        echo "<td valign=bottom align=center bgcolor=darkslateblue>";

        echo "<center>";
        $random=Round((double)microtime()*2);
        if($random<=0) $random=1;
        if($random>2) $random=2;
        echo "<img src=images/title/$random.gif height=100 width=230>";
        echo "</center>";

        echo "<br><br>";
        echo "<A HREF=member.php?action=editprofile><img src=images/top_profile.gif alt=Edit your profile border=0></A>";
        echo "<A HREF=member.php?action=signup><img src=images/top_register.gif alt=Registration is free border=0></A>";
        echo "<A HREF=memberlist.php><img src=images/top_members.gif alt=Find other members border=0></A>";
        echo "<A HREF=index.php?action=faq target=_blank><img src=images/top_faq.gif alt=Frequently Asked Questions border=0></A>";
        echo "<A HREF=search.php><img src=images/top_search.gif alt=Search border=0></A>";
        echo "<A HREF=index.php><img src=images/top_home.gif alt=Home border=0></A>";
        echo "</td>";
        echo "</tr>";
        echo "</table>";

        Comment


        • #5
          You shouldn't use echo() in the header, as it messes up the setcookie() calls

          Comment


          • #6
            I see why now

            Comment

            widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
            Working...
            X