PHP on HTML pages
Results 1 to 5 of 5

Thread: PHP on HTML pages

  1. #1
    Senior Member
    Join Date
    Jun 2003
    Posts
    219

    PHP on HTML pages

    Hi all,

    I have completed my whole site in HTML.

    I have my login page in php.

    Some one suggested me that there there can be a small code which can be added in all the pages, and after changing the extn to php, I can use sessions in all of the site.

    Can this be possible?

    If yes, can someone provide me that code?
    I dont want to make many changes in the site now.

    thanks
    riya
    Now is the moment, or NEVER!!!

  2. #2
    Elite Hacker
    Join Date
    Mar 2003
    Posts
    1,407
    Just add...
    PHP Code:
    <?php
    session_start
    ();
    ?&
    gt
    to the top of all your pages. When they login you can add their username to the $_SESSION array.
    PHP Code:
    <?php
    $_SESSION
    ['username'] = $_POST['username'];
    ?&
    gt
    Then everywhere you want to print their username just do this...
    PHP Code:
    <?php echo $_SESSION['username']; ?&gt
    and when you want to log them out you can do this...
    PHP Code:
    <?php
    $_SESSION 
    = array();
    session_destroy();
    ?&
    gt
    Keep in mind this does nothing for input validation. You want to make sure you do not fall victim to XSS or SQL injection if you end up using a database. There is a tutorial around by chsh for input validation and another by catch on shoestring sql stuff I think. Do a search here so you can try and avoid such things. Hope this helps.

  3. #3
    Senior Member
    Join Date
    Jun 2003
    Posts
    219
    thanks
    Now is the moment, or NEVER!!!

  4. #4
    Senior Member
    Join Date
    Jun 2003
    Posts
    219
    Hi,

    I am able to start the sessions but unable to destroy them.

    I have created a logout.php file in which I have written the following code.
    <?php
    @session_unset();
    $_SESSION = array();
    @session_destroy();
    ?>
    and in all other php files i have written the code to start the session.

    Please help.
    Now is the moment, or NEVER!!!

  5. #5
    Elite Hacker
    Join Date
    Mar 2003
    Posts
    1,407
    Is it giving you an error or are you just still logged in?

Posting Permissions

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