I'm trying to save a variable to a text file using PHP code. Everything else works apart from line 33 of my code, where I try and pass an HTML variable into PHP, in order to save that variable to my text file. Wouldn't like to use forms as I don't want to change my earlier code round too much as it's taken me ages to get it to work.
Have already tried, $_GET
and $_REQUEST
<DOCTYPE.html>
<html>
<body>
<h3>Please enter your UN and PW</h3>
<p id="demo"></p>
<p id="demo1"></p>
<p id="demo2"></p>
<script>
var username, password, x, INput;
username = prompt("Username: ");
password = prompt("Password: ");
document.getElementById("demo").innerHTML= "UN: " + username;
document.getElementById("demo1").innerHTML = "PW: " + password;
x = (password<=0) ? "No":"Yes";
document.getElementById("demo2").innerHTML = "Typed password: " + x;
INput= String(username + ", " + x + "\n" )
alert(INput);
</script>
<?php
// Open the text file
$f = fopen("textfile.txt", "a");
// Write text line
fwrite($f, #######);
// Close the text file
fclose($f);
?>
</body>
</html>
The "##s" are where I would like "INput" to go, but it doesn't work as it is an html variable.
Expected Output: INput will save to the "textfile.txt" file
Actual Output: "Notice: Use of undefined constant INput - assumed 'INput' in /storage/ssd1/856/9172856/public_html/UNPW.php on line 33"
EDIT: Using 000webhost.com, if this changes anything