Change defined variable and receive new value via form

0

I have a variable $ CONFIG ['SiteTitle'] = 'Title of my site';

This variable is in the config.php file and even the header to define the title of all the pages. Recently create a new page for the site the general settings. On this page I want to put a form where I can change the value of this variable $ CONFIG ['SiteTitle'] .

<form>
   <label>Titulo do site:</label>
   <input type="text" value="<?php echo $CONFIG['SiteTitle']; >">
</form>
    
asked by anonymous 07.03.2018 / 02:33

1 answer

0

In form, send the text of the new page to php per post:

<form method="post" action="caminho/config.php">
    <input type="text" name="titulo">
</form>

In the config.php page, check if the post exists and if it is not empty, then assign its value to the variable:

if(isset($_POST["titulo"]) && $_POST["titulo"] != "")
    $CONFIG["SiteTitle"] = $_POST["titulo"];
    
07.03.2018 / 02:51