0
I have a config.php file with several defines through a form.
If there is such a definition:
define("NAME","Rodrigo");
and another like:
define("MEU_NOME","Rodrigo");
and in my HTML I have only ONE input:
<?php include(config.php) ?>
<input type="text" id="NAME" value="<?=NAME?>" name="MSSQL_Pass">
If the input sends the name "Danilo", it saves this name in both defines, even though I have no other input with the ID and NAME equal to the define I want to save.
This is my job:
function write(){
$file = fopen("config.php","rb");
$MainContents = "";
while(!feof($file)) $MainContents .= fgets($file);
fseek($file, 0);
while(!feof($file))
{
$Main = fscanf($file,'%[^;]');
if(strpos($Main[0],"//") === false && strpos($Main[0],"?") === false && isset($Main[0]))
{
$data = explode("\",",$Main[0]);
$const = str_replace("define(\"", "", $data[0]);
$value = str_replace(")", "", $data[1]);
$myVar = trim($const);
if(!empty($_POST[$myVar]))
{
$new = ($_POST[$myVar] == "true" || $_POST[$myVar] == "false") ? $_POST[$myVar] : "\"" . $_POST[$myVar] . "\"";
$MainContents = str_replace($value, " " . $new ,$MainContents);
}
}
}
fclose($file);
$file = fopen("config.php","wb");
fwrite($file, $MainContents);
fclose($file);
echo " <div class=\"success-box\">Configurações salvas com sucesso!</div>";
}
How can I fix this?
ele grava esse nome nos dois defines
- What do you mean Record in Constants??? Modify this question, friend.– William Aparecido Brandino
It’s really not making it very clear, but it’s not changing the constant itself, but physically the file that generates the constant.
– Kenny Rafael