Oops! I figured it out. Had to strip slashes...
Hello, I have the following code to edit my configuration file in the browser. The file content is retrieved and displayed in a text box. Then the edits are saved back into the file. Everything works fine on my development machine but in my hosting account it does not work.
When I save the file, all single quotes are over written adding a backslash in front of them.
How can I change my code to prevent this? Thank you!
<?php
// button javascript
$save_changes_js = "return confirm('Do you want to SAVE the CHANGE(S)?');";
// open web config
$filename = ROOT_PATH.'web.config.php';
$contents = file_get_contents($filename);
if(isset($_POST['txbConfig']) && !empty($_POST['txbConfig']))
{
// save changes to file
$changes = $_POST['txbConfig'];
file_put_contents($filename,$changes);
// refresh page
$destination_url = SITE_URL.'admin/edit-config.php';
header('Location:'.$destination_url);
}
?>
<form action="" method="post" name="editConfig" class="htmlForm">
<div class="editConfigWrap">
<textarea name="txbConfig"><?php echo $contents ?></textarea>
</div>
<input name="submit" type="submit" value="Save Changes" class="gvbtn" onclick="<?php echo $save_changes_js; ?>">
</form>