SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Member
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can someone check my code for me

    Okay, i have wrote a login, register script.But my script dont write the cookies...can check for me

    Code:

    <?php

    $data = file(users.txt');
    foreach($data as $key=>$element) {
    $element = trim($element);
    $pieces = explode("|", $element);
    if($pieces[0]==$usernama && $pieces[1]==$password) {

    setcookie("username","$usernama",time()+1012324305);
    setcookie("logapagak","yes",time()+1012324305);
    header("Location: index.php");
    }

    else {
    header("Location: index.php");
    }
    }

    ?>

  2. #2
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    are you receiving a warning message?

  3. #3
    SitePoint Member
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope...it juz refresh back to index

  4. #4
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, the probably the problem is your browser. If you are using NN 6.x or IE 6.X check if both are accepting cookies

  5. #5
    SitePoint Member
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay. can i try for me i urs work?
    http://novasg.com/ss

  6. #6
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, but I need at least a demo user/password pair

  7. #7
    SitePoint Member
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay..user and pass "123"

  8. #8
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, it's not sending the cookies. Try this. At the top of your script, in index.php, put this

    cookie('dummy','dummy');

    Let me know when it's done

  9. #9
    SitePoint Member
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    erm..i using header and footer.....index is juz the content....where to add?

  10. #10
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, I've checked your code again and there's an error there. You should use
    PHP Code:
    $data file(users.txt');
    foreach($data as $key=>$element) 
    {
        $element = trim($element);
        $pieces = explode("|", $element);
        if($pieces[0]==$usernama && $pieces[1]==$password) 
        {
            setcookie("username","$usernama",time()+1012324305);
            setcookie("logapagak","yes",time()+1012324305);
        }
    }
    header("Location: index.php" ); 
    Paul

  11. #11
    SitePoint Member
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Parse error: parse error, unexpected '\'' in C:\webspace\nov2002\novasg.com\novasg.com\www\ss\login.php on line 3

  12. #12
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there's a missing quote here

    $data = file(users.txt');

    just add it.

  13. #13
    SitePoint Member
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    erm ....can write the whole code for me?

    this is my


    <?php

    $data = file('usersgakbolehdiliatinitaugaksih.txt');
    foreach($data as $key=>$element) {
    $element = trim($element);
    $pieces = explode("|", $element);
    if($pieces[0]==$usernama && $pieces[1]==$password) {

    setcookie("username","$usernama",time()+1012324305);
    setcookie("logapagak","yes",time()+1012324305);
    header("Location: index.php");
    }

    else {
    header("Location: index.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
  •