I realized that the script I wrote is attempting to use both javascript and php, and this doesn’t work. Can anyone tell me how I might go about achieve what I’m looking to do? What I want to do is have a button that when clicked, it will write to file on the server. Here;s the code i wrote:
<html>
<head>
<?php
function change_html(){
$myFile = "testFile.html";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Hello\n";
fwrite($fh, $stringData);
$stringData = "World!\n";
fwrite($fh, $stringData);
fclose($fh);
}
?>
</head>
<body>
<input type="button" onclick="change_html()" Value="Continue">
</body>
</html>
Thanks in advance!!
If you want to do this in PHP, then you have your button submit a form and the PHP script it points to does the work.
–
That script can redirect back to the form if you want: