Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: PHP Login Help

  1. #1
    Join Date
    Nov 2005
    Posts
    18
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default PHP Login Help

    Can someone check out the files i've uploaded? I've got a simple username and password login form that works except for the fact that you have submit the username and password twice in order to be redirected to the according page.

    username: tst
    password: your_password
    Last edited by wyclef; 01-20-2006 at 06:17 PM.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It redirects me to a page on a different server, the source of which I cannot see.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Nov 2005
    Posts
    18
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    I updated the zip files to take that URL out. That should just be the URL of wherever the login page resides...(i think)

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Works here for me.
    httpd-2.0.54-10.2
    php-5.0.4-10.5
    Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.8) Gecko/20051201 Fedora/1.5-1.1.fc4.nr Firefox/1.5 - Build ID: 0000000000

    See at http://twey.ath.cx/pass/login.php
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Nov 2005
    Posts
    18
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    lol. it's broken i swear! well, yours definitely seems to be working properly. ummm... do you think a base href tag at the top of the page could effect anything? also, the code seems a bit messy to me, do you have any advice on how to clean it up? i might strip out the base href tag on the version i'm using and see if that fixes the problem. i'm not exactly sure why this works now.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    do you think a base href tag at the top of the page could effect anything?
    Not unless you later try to use header() to redirect.
    As to neatening up the code, try using an include to check the session.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Nov 2005
    Posts
    18
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    would you say this new code is much better?

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Why are half your linebreaks UNIX-style and half Windows-style? It confuses my poor editor... :-\
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Nov 2005
    Posts
    18
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Sorry, the other person giving input on my code must be on windows...

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Sorry, I lied: they're half-UNIX, half-old Mac.
    What I meant was to put the login-checking bit in a seperate file, say "security.php":
    PHP Code:
    <?php

    function login_fail() {
        
    header('Location: /');
        exit;
    }

    // start the session
    session_start();

    // is the one accessing this page logged in or not?
    if ($_SESSION['username'] != "tst 1060b7b46a3bd36b3a0d66e0127d0517") {
        
    // not logged in, fail
        
    login_fail();
    }

    ?>
    then include it into page.php:
    PHP Code:
    <?php require_once("security.php"); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        <head>
            <title>Page</title>
        </head>

        <body>
            The page you are redirected to upon successful login
        </body>
    </html>
    This will make life a lot easier for you later on.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •