PHP Config File Mod Help

1 replies
I have a simple one line config file...

<?php

$clickbanknickname = "namegoeshere";

?>

I need some kind of form or admin panel that will allow my customers to easily change the above file (it will be hosted on my server)

Is there a way to maybe have them fill out a one field form with their CB nickname, send that to a text file on my server and then "include" that text file in the above config?

Thanks,
George
#config #file #mod #php
  • Profile picture of the author Darren Mothersele
    assuming you want them to supply a password in order to change the value. in one file you have code like this:

    <?php
    if ($_REQUEST['password'] == 'secret-password-here') {
    $myFile = "configfilename.inc";
    $fh = fopen($myFile, 'w') or die("can't open file");
    fwrite($fh, $_REQUEST['cbusername']);
    fclose($fh);
    } else {
    // print a form here with password and cbusername field
    }
    ?>

    In your config file use file_get_contents('configfilename.inc') to read in the value from the config file as a string.

    This is only a very basic script - you should probably do more validation of user input.
    {{ DiscussionBoard.errors[350750].message }}

Trending Topics