Screwing up a simple script.

Alright. I’m sure I’m making this more difficult that it needs to be.

I’m trying to have a script pull the contents of a text file into a textbox. People would then be able to edit the text box, click “submit”, and the changes would be written to the text file.

Here’s what I have.
[php]



<?php $list = file_get_contents('whitelist.txt'); ?> <?=$list?>
<?php $changes = @$_GET["editwhitelist"]; file_put_contents ($list, $changes); ?> [/php]

It works, to an extent. It DOES draw the text from the file. However, no one can update the file.

I have had minimal success with writing. At some point I had a glitch where clicking “Submit” would delete the contents of the file. It wasn’t doing what I wanted, but at least it was making changes!

[php]

<?php $list = file_get_contents('whitelist.txt'); ?> <?=$list?>
<?php

$changes = @$_GET[“editwhitelist”];
file_put_contents ($list, $changes);
?>

[/php]

let me know if it works

It does the same thing as before. :frowning:

[php]

<?php if (isset($_GET['update'])) { $changes = @$_GET["editwhitelist"]; file_put_contents ("whitelist.txt", $changes); } $list = file_get_contents('whitelist.txt'); ?> Update White List <? echo $list?>
[/php]

How about now?

Aha! That’s done it! Thank you, so much. :slight_smile:

Glad that i could help, what you were doing wrong was you were not giving a file name in this line
[php]
file_put_contents (“whitelist.txt”, $changes);
[/php]

I will mark this thread solve now

Sponsor our Newsletter | Privacy Policy | Terms of Service