PHP
<?php
if ($changefile) {
$savedEdit = stripslashes($_POST['filetest']);
$filetochange = "../dashboard/list.ini";
$filetochangeOpen = fopen($filetochange,"w") or die ("Error editing.");
fputs($filetochangeOpen,$savedEdit);
fclose($filetochangeOpen) or die ("Error Closing File!");
}
?>
HTML form
<form method=post action="mmtst.php">
<textarea rows="40" cols="60" name="filetest">
<?
// Implode CSS
$filetochange = "../dashboard/list.ini";
print (implode("",file($filetochange)));
?>
</textarea><br/><br/>
<input type="submit" value="Save Changes" name="changefile">
</form>
Here I have a page that displays an INI file in a text box. What should happen is that when I click the submit button, the original file is opened, and fputs writes to the original with anything that is displayed in the txtbox. (the original file is set to permissions 777). However, nothing happens when the submit button is clicked, I have no idea what I am doing wrong, any suggestions would be awesome.
The issue is simple, you have register_globals disabled and you are trying to use it, this setting allow PHP to automatically define variables depending on received parameters from GET and POST data, but it’s considered insecure and has been deprecated.
To access the values passed in a post for use the $_POST variable, for get use the $_GET
In case you just want to check if a post form as been submitted you could
!empty($_POST)and leave the submit button without name: