Jump to content

Updating constants in a file


allex01

Recommended Posts

I have a file that contains all types of constants that looks like this

 

$CFG['admin']['value']['article_value'] = '9';

$CFG['admin']['value']['article_upload_value'] = '10';

$CFG['admin']['value']['game_comment_value'] = '11';

 

I created a form with input fields where a user can input and change the values for article_value, article_upload_value, game_comment_value. My question is , how can i make those values replace the current values in the constant file when the submit button is hit. You don't have to work with my current scheme. A simple example on how to update constants in a file would be helpfull. 

Link to comment
Share on other sites

Do i still need to use fwrite()

 

If you want to actually overwrite the values in the file.

 

If you just want them temporarley overiden you would use something like....

 

<?php

  if (isset($_POST['submit'])) {
    $CFG['admin']['value']['article_value'] = $_POST['admin_value_article_value'];
    $CFG['admin']['value']['article_upload_value'] = $_POST['admin_value_article_upload_value'];
    $CFG['admin']['value']['game_comment_value'] = $_POST['admin_value_game_comment_value'];
  }

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.