Results 1 to 4 of 4

Thread: [RESOLVED] PHP at begining of HTML document?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    Resolved [RESOLVED] PHP at begining of HTML document?

    Hello here is my code:

    Code:
    <?php
    session_start();
    if (isset($_SESSION['loggedon']) == false){
    header('Location: /index.html');
    }
    ?>
    <html>
    <body>
    Secret Content!
    </body>
    </html>
    This is a .html page. My php code is not be processed. The loggedon is not set which should cause the header to execute, but instead nothing happens. As well when you viewsource the page you can see the php code. Is it not valid to place PHP code before the html tags? If it isn't valid then where do I put the session_start();? Where do I put my php code?

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: PHP at begining of HTML document?

    the file needs to be .php

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    Re: PHP at begining of HTML document?

    And I can still have the html tags?

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: PHP at begining of HTML document?

    yes. PHP files can contain all php, all html, or php and html together.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width