Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Nov 2003
    Location
    Singapore
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating Login without Database

    I know that somehow i could create a secure login without using any databases. Someone told me that i could create a script that stores Username and Passwords using arrays. Is that 100% true? if so can someone kindly post the script here? Im not sure how to go about using arrays.

    Thanks alot.

    -noXen
    There are only two ways to live ur life, one is as though nothing is a miracle, the other is as though everything is a miracle.

  • #2
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sure, you could store them in arrays, but thats not really safe. I think the only really safe way is using the database. htaccess is pretty safe, but it all depends on what your protecting. If your protecting very confidential stuff, I'd use the database because its kinda hard to get into it. If your protecting stuff thats not really gonna harm anyone else to see, then use .htaccess.

    The only really secure way I can think of is encrypt, using PHP's md5() function, your password into the database.

    Hope this helps,

    Steve
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #3
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    im not saying arrays is as secure as database, but surely if the info was stored as username/md5 password its gonna be just as hard to crack?

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    htaccess is about just as safe as any other password protection too. Only way you're gonna get the password file is by brute force and if they gonna get it by brute force, then no password protection will work anyway as they'd (the script kiddies) would already be inside your webroot and could just download everything

  • #5
    New Coder
    Join Date
    Nov 2003
    Location
    Singapore
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well i just started learning php, so the guy who taught me the basics said using databases is very complicating. he advised me to use arrays since i would only have 10 logins and passwords MAXIMUM. Since my site doesnt have any very important information i think it doesnt need to be 100% secure.

    If anyone can help me make a list of the 10 logins and passwords using arrays, such that i just need to fill in the logins and passwords, that would truely be useful.

    PS: I would like it in php syntex please

    Hope u guys could help.

    Thanks!

    -noXen
    There are only two ways to live ur life, one is as though nothing is a miracle, the other is as though everything is a miracle.

  • #6
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've never done it with arrays, but I have done it this way =
    PHP Code:
    <?php
    $username 
    $_POST['username'];
    $password $_POST['password'];
    $actualusername "noxen";
    $actualpassword "password";

    if(
    $username == $actualusername && $password == $actualpassword){
    echo 
    "You got in......";
    }
    else {
    echo 
    "Wrong password and/or username";
    }
    ?>
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #7
    New Coder
    Join Date
    Nov 2003
    Location
    Singapore
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thx guys for replying.

    hey SDP2006, so if i have 10 logins and passwords i just keep adding this part?

    $actualusername = "noxen";
    $actualpassword = "password";


    So meaning the code would look something like that for 10 users?

    PHP Code:
    <?php
    $username 
    $_POST['username'];
    $password $_POST['password'];
    $actualusername "noxen";
    $actualpassword "password";
    $actualusername "user2";
    $actualpassword "password";
    $actualusername "user3";
    $actualpassword "password";
    $actualusername "user4";
    $actualpassword "password";
    $actualusername "user5";
    $actualpassword "password";
    $actualusername "user6";
    $actualpassword "password";
    $actualusername "user7";
    $actualpassword "password";
    $actualusername "user8";
    $actualpassword "password";
    $actualusername "user9";
    $actualpassword "password";
    $actualusername "user10";
    $actualpassword "password";

    if(
    $username == $actualusername && $password == $actualpassword){
    echo 
    "You got in......";
    }
    else {
    echo 
    "Wrong password and/or username";
    }
    ?>
    Am i right? Thanks.

    -noXen
    There are only two ways to live ur life, one is as though nothing is a miracle, the other is as though everything is a miracle.

  • #8
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm not sure if that will work. You'll have to test it.
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #9
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    no, it wont, try:

    PHP Code:

    <?php

    $usr_username 
    $_POST['username'];
    $usr_password $_POST['password'];

    $users = array();
    $passwords = array();

    $users[0] = 'user1';
    $passwords[0] = 'pass1';

    $users[1] = 'user1';
    $passwords[1] = 'pass1';

    for(
    $i=0;$i<count($users);$i++){

          if(
    $users[$i] == $usr_username && $passwords[$i] == $usr_password){

               
    // success

          
    } else {

               
    // failure

          
    }

    }

    ?>

  • #10
    New Coder
    Join Date
    Nov 2003
    Location
    Singapore
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks missing-score,

    Will try that tomorrow morning, its 3am now

    Hope it works. Thanks again!
    There are only two ways to live ur life, one is as though nothing is a miracle, the other is as though everything is a miracle.


  •  

    Posting Permissions

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