I
I
iDezz2019-02-20 16:58:07
PHP
iDezz, 2019-02-20 16:58:07

How to replace one or more variables from one php file to another?

Hello, there is an index.php file on which the form is in the form "Login, Password, submit button". It is necessary that when you click on the "send" button, these data are overwritten in the account.php file, it looks like this:

<?php
$data= ['login' => 'Admin', 'password' => 'admin'];
?>

Who cares, tell me how to implement it)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
riot26, 2019-02-20
@riot26

It is correct to use a DB for such things.
This is how you can, God forgive me:

$content = '<?php' . PHP_EOL;
$content .= '$data= [\'login\' => \'' . $_POST['login'] . '\', \'password\' => \'' . $_POST['password'] . '\'];' . PHP_EOL;
$content .= '?>';

$fp = fopen('account.php','w');
fwrite($fp, $content);
fclose($fp);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question