SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm trying to create a form whereby I can edit the variables with just the form.

    It will be something like a form for me to change the database details(username,server,password) in a .inc I'm using.

    Is there anyway for me to pass information into another file's variable and have it saved in there?

  2. #2
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes... there is a way:

    insert your information into a flatfile... then use explode to get your usernames/passwords:

    PHP Code:
    $vars explode(" "$file_with_data);

    $username $vars[0];
    $password $vars[1];
    $database $vars[2]; 
    Not real hard! Sorry for overlooking your post!
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    do you mean,

    $file_with_data will be assigned to the location of the file ?

    like :

    $vars = explode(" ", flatfile.txt); ?

    Could you give an example of whats in the flatfile and whats the source for the explode ?
    Hope I'm not asking too much

  4. #4
    SitePoint Addict
    Join Date
    Nov 2000
    Location
    London, UK
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this
    flatfile (probably .php3, so that its not viewable by others):
    say you decided to make it so that you've got
    server|username|database in your .inc. It would look like this

    info.php3 (or inc)
    Code:
    myserver|myusername|mypassword
    then the retrieving file could be this
    PHP Code:
    // make this your info file
    $incfile "info.inc";

    // get the info
    list($server,$username,$password) = explode("|",implode(file($incfile),"")); 
    Then $server would be your servername, $username your username, $password your password, etc.

    if you decided to change the order of things, then you'd have to change the order of the variables in list(..) accordingly.

    you don't need the code for any of the functions used .. they're all inbuild functions
    for more info, go to
    http://www.php.net/list, http://www.php.net/explode, http://www.php.net/implode, http://www.php.net/file

    Good Luck

    ... what's the world coming to?

  5. #5
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    for my .inc, I need it to assign the variables also

    Lemme give you an example :

    PHP Code:
    $dbhost 'localhost'
    $dbuser 'user'
    $dbpass 'pass' 
    And then I'll be using a form to modify the .inc from outside.

    The above post is only when the files are like ?
    PHP Code:
    localhost user pass 
    Can someone give me an example now ?

  6. #6
    imagine no limitations exbabylon's Avatar
    Join Date
    Dec 2000
    Location
    Idaho, USA
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    file that you're going to modify:

    vars.inc:
    Code:
    localhost | user | pass

    The Include File Your Using *.inc file:
    PHP Code:
    // file to include:
    $incfile "vars.inc";

    // get the info
    list($server,$username,$password) = explode("|",implode(file($incfile),"")); 
    Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.

    Exbabylon- Professional Internet Services


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
  •