Activity Stream
48,167 MEMBERS
6945 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 5 of 5
  1.     
    #1
    Member
    Website's:
    porndex.eu massprchecker.com

    Default changing config.php via php page

    Ok so im trying to write to my config.php from admin/index.php

    Im managing to do this, BUT it erases everything and just writes to the php file what i asked.
    I want it to alter the string not delete the lot lolz

    Example

    My config file looks like this ( or some of it anyway)

    PHP Code: 
    <?php

    // Latest DVD

    // Movie 1

    $l1 "X-MAN";
    $l2 "movie1.jpg";
    $l3 "";


    // Movie 2

    $l12 "X-MAN";
    $l22 "movie2.jpg";
    $l32 "Hello World!";

    // Movie 3

    $l13 "X-MAN";
    $l23 "movie3.jpg";
    $l33 "";

    My admin/index.php looks like this

    PHP Code: 
    $string = '<?php 
    $l13 
    "'. $_POST["l13"]. '";

    ?>';
     
    $fp = FOPEN("config.php", "w");
    FWRITE($fp, $string);
    FCLOSE($fp);
     
    }
     
    ?>
     
    <form action="" method="post" name="install" id="install">
      <p>
        <input name="l13" type="text" id="l13" value=""> 
        l13 text
    </p>
       <p>
        <input type="submit" name="Submit" value="Install">
      </p>
    </form>

    And the result looks like this AND ONLY THIS all other has gone

    PHP Code: 
    <?php 
    $l13 
    "pleasework";

    ?>
    So its writing ok but i dont want it to write a new file just update the $l13 output


    Help please

    Cheers
    RR
    roadrunner Reviewed by roadrunner on . changing config.php via php page Ok so im trying to write to my config.php from admin/index.php Im managing to do this, BUT it erases everything and just writes to the php file what i asked. I want it to alter the string not delete the lot lolz Example My config file looks like this ( or some of it anyway) <?php Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    epicimagehost.com
    Seems like you're better of using a database.

  4.     
    #3
    Member
    I think the 'w' creates a new file but you want to append to the file, google it.


    Like Robin H said, use a database.

  5.     
    #4
    Member
    Website's:
    PasteBot.appspot.com
    I think you need to open the file in append mode. See if this works.
    PHP Code: 
                           $string = '<?php  
    $l13 
    "'. $_POST["l13"]. '"

    ?>'; 
      
    $fp = FOPEN("config.php", "a"); 
    FWRITE($fp, $string); 
    FCLOSE($fp); 
      

      
    ?> 
      
    <form action="" method="post" name="install" id="install"> 
      <p> 
        <input name="l13" type="text" id="l13" value="">  
        l13 text 
    </p> 
       <p> 
        <input type="submit" name="Submit" value="Install"> 
      </p> 
    </form>
    EDIT: I just replaced 'w' with 'a'
    I am just guessing. I have no idea if php has an append mode.

  6.     
    #5
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    Quote Originally Posted by ajinkya9 View Post
    I think you need to open the file in append mode. See if this works.
    PHP Code: 
                           $string = '<?php  
    $l13 
    "'. $_POST["l13"]. '"

    ?>'; 
      
    $fp = FOPEN("config.php", "a"); 
    FWRITE($fp, $string); 
    FCLOSE($fp); 
      

      
    ?> 
      
    <form action="" method="post" name="install" id="install"> 
      <p> 
        <input name="l13" type="text" id="l13" value="">  
        l13 text 
    </p> 
       <p> 
        <input type="submit" name="Submit" value="Install"> 
      </p> 
    </form>
    EDIT: I just replaced 'w' with 'a'
    I am just guessing. I have no idea if php has an append mode.
    The php do have append mode but it is not used for this purpose

    ------------------------------------------------------

    Either use what gavo said

    Or Other possible ways:

    1.
    Show all the values in the "admin/index.php" from php file when the page loads

    If you dont want to show specific values, then you can keep it hidden

    Then get all the specific values and save the file

    2.
    Open the file! Get it all contents using whichever mode you prefer
    Then make a regex replacement for the current vars with the new vars
    Save the new text

    Hope it helps

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Changing your page structure in RVSiteBuilder
    By Areon in forum Server Management
    Replies: 0
    Last Post: 3rd Mar 2014, 03:20 PM
  2. What's Your PC Config ?
    By Froomple in forum General Discussion
    Replies: 46
    Last Post: 5th Jul 2011, 07:55 AM
  3. Config DLE
    By duonglg in forum DLE
    Replies: 4
    Last Post: 14th Jun 2011, 06:27 AM
  4. Changing config file name
    By Shadow008 in forum vBulletin
    Replies: 11
    Last Post: 7th Jan 2011, 04:44 PM
  5. Blank page after changing hosting company
    By desibreaker in forum Server Management
    Replies: 9
    Last Post: 26th Oct 2009, 09:48 PM

Tags for this Thread

BE SOCIAL