Web Hosting Forums

Results 1 to 7 of 7

This is a discussion on php login and logout help please in the Hosting Talk & Chit-chat forum
ok the code I am using will not work out right, yet im sure ive got it all right 1. here is the link http://216.118.121.28/admin.php ...

  1. #1
    Loyal Client
    Join Date
    Feb 2002
    Posts
    90

    php login and logout help please

    ok the code I am using will not work out right, yet im sure ive got it all right


    1. here is the link http://216.118.121.28/admin.php

    2. here is the code http://216.118.121.28/admin.txt

    3. here is the error im getting when im trying to logout of the script

    PHP Code:
    WarningCannot add header information headers already sent by (output started at /home/samcoleb/public_html/admin.php:2in /home/samcoleb/public_html/admin.php on line 9

    Warning
    Cannot add header information headers already sent by (output started at /home/samcoleb/public_html/admin.php:2in /home/samcoleb/public_html/admin.php on line 10 
    now when I also try to login the code won't work also

    would someone be able to fix it for me?

    thanks

  2. #2
    Chairman Still Shady's Avatar
    Join Date
    Sep 2001
    Location
    Redmond, WA-nnabe
    Posts
    1,184

    Try this!

    Find:
    <? if ($action == "login") {
    if ($username == "admin" || $password == "admin") {
    setcookie("admin", "loggedin", "+3600");
    header('Location: admin.php');
    } else { echo "wrong password";
    }
    } elseif ($action == "logout") {
    setcookie("admin", "loggedout", "-3600");
    header('Location: http://216.118.121.28/pw/'); }?>


    Replace with:

    <?

    if ($action == "login") {
    if ($username == "admin" || $password == "admin") {
    setcookie("admin", "loggedin", "+3600");
    header('Location: admin.php');
    }
    else {
    $error = "wrong password";
    }
    }
    elseif ($action == "logout") {
    setcookie("admin", "loggedout", "-3600");
    header('Location: http://216.118.121.28/pw/');
    }


    echo $error
    ?>

    It doesn't like the printing directive when there are header functions ascending to the code.
    Where do you wanna go today?

  3. #3
    Loyal Client
    Join Date
    Feb 2002
    Posts
    90
    thanks trying that now

    so basically I needed to clean the script up a bit?

    thanks

  4. #4
    Chairman Still Shady's Avatar
    Join Date
    Sep 2001
    Location
    Redmond, WA-nnabe
    Posts
    1,184
    Yup... you have to practice clean coding with blocks (tabs), I dunno, whatever's readable to you... Did it work? Good Luck!
    Where do you wanna go today?

  5. #5
    Loyal Client
    Join Date
    Feb 2002
    Posts
    90
    thanks for that now I can have a go at rest my attemp of my news script

    any suggestions on tutorials fo rediting and delteing news using a flat file database.

    I prefer that then mysql for news so any help would be great

    and still shady chack back on the php link now it does work

    admin/admin

    thanks

  6. #6
    Chairman Still Shady's Avatar
    Join Date
    Sep 2001
    Location
    Redmond, WA-nnabe
    Posts
    1,184
    Flat file can be hasle sometimes due to Read and Write Permissions... MySQL is cool! The only site I go when I need help is http://www.phpbuilder.com just search their forums for answers or ask there for some help. They are pretty good.

    Lots of things/techniques you can do in php...
    Where do you wanna go today?

  7. #7
    Loyal Client
    Join Date
    Feb 2002
    Posts
    90
    cool and thanks I will look around

    if I need anyhelp I will ask here with whatever scripts I am using

    thanks again

Bookmarks

Posting Permissions

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