Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Senior Member [Li] Brad's Avatar
    Join Date
    Oct 2003
    Location
    Saskatoon, Canada
    Posts
    578
    Member #
    3689
    Hello all!

    I am a bit stumped as I am recent to PHP (about 3 months ago) and I was wondering about the dependability of the following:

    Scenario:
    I have an array with names and passwords (sensitive information!) and I want to be able to use it and have it work in PHP only (no MySQL). So far I have this, among other things:
    (sensitive info has been replaced with 'xyxyxy')
    PHP Code:
    $i 0;
    $element = -1
    $result count($idarray);
    $found 0;
    if (
    $id!="" && $pw!=""){
        if (
    $id=="xyxyxy" && $pw=="xyxyxy"){
            
    header("Location: [url]http://www.xyxyxy[/url]");
            exit;
        }
        do {
            
    $element $element 1;
               if (
    $id==$idarray[$element] && $pw==$pwarray[$element]){
                echo 
    "<table width=\"800\" border=\"1\" cellpadding=\"3\" cellspacing=\"0\" bordercolor=\"#CCCCCC\">";
                echo 
    "<tr bgcolor=\"#EEEEEE\">";
                echo 
    "<td width=\"612\">Show Room for $id</td>";
                echo 
    "<td>$id's Options</td>";
                echo 
    "</tr>";
                echo 
    "<tr>";
                echo 
    "<td>";
                
    $page $id ".php";
                
    $page strtolower($page);
                
    $page "_" $page;
                include(
    $page);
                echo 
    "</td>";
                echo 
    "<td bgcolor=\"#FFFFFF\">Your password is: $pw</td>";
                echo 
    "</tr>";
                echo 
    "</table>";
                
    $found 1;
                exit;
            }
            
    $i $i 1;
        } while (
    $i<=$result);
    }
    else{
        echo 
    "Please fill in all the fields.";
        
    $found 1;
    }
    if (
    $found == 0){
        echo 
    "Login Failed!<br>You may have entered invalid information.";
    }
    ?> 
    This .php file is the 'action' of an html form. Now, at the top of this .php file, I have a temporary array like this:
    PHP Code:
    $idarray[0] = "xyxyxy";
    $pwarray[0] = "xyxyxy";
    $idarray[1] = "xyxyxy";
    $pwarray[1] = "xyxyxy"
    And so on. Rather than modify the code to add more ids and passwords, I will eventually have a script that appends the new id and pw to the array info. What I am wondering is: is there a safe way to store my array info in a file so no one can just open it and find all that info? Also I would need to use a
    PHP Code:
    require_once('xyxyxy.xyx'); 
    to use the array info, right? Can anyone help me?

    [Li] Brad
    "Art strives for form, and hopes for beauty." - George Bellows

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Okie dokie..... a few issues:
    1. Whether you're storing your passwords in a database or a text file, they should be MD5 encrypted
    2. A text file will always be less safe than a database... if you want to increase security, place it in a folder that has no public permissions
    3. You shouldn't have two arrays for ids and passwords, instead, have a multidimensional array using numeric and associative indexes... like so:
      $logins[0]["username"]="joe";
      $logins[0]["password"]="schmo";
      $logins[1]["username"]="stevie";
      $logins[1]["password"]="weevie";
    4. If you're storing information into a text file, why not use XML? It's easier to read than plain text.... look into PHP's DOM utilities.

  4. #3
    Senior Member [Li] Brad's Avatar
    Join Date
    Oct 2003
    Location
    Saskatoon, Canada
    Posts
    578
    Member #
    3689
    Thanks! I'll look into your suggestions.

    [Li] Brad
    "Art strives for form, and hopes for beauty." - George Bellows


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:39 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com