I am trying to make this php function get called on a press of a button (create).
<?php
$myfile = fopen("details.txt", "a") or die("Unable to open file!");
$txt = "John Smith\n";
fwrite($myfile, $txt);
$pwd = "123456\n";
fwrite($myfile, $pwd);
fclose($myfile);
?>
I tried this in JS: function Create(){
<?php
$myfile = fopen("Details.txt", "a") or die("Unable to open file!");
$txt = "John Smith\n";
fwrite($myfile, $txt);
$pwd = "123456\n";
fwrite($myfile, $pwd);
fclose($myfile);
?>
}
and this in html
<form name="userForm" onsubmit="return validateForm()" >
Enter your name:<br> <input type="text" name="name" id="name"> <br>
Enter your password: <br><input type ="password" name="password" id="password">
<br>
<button type="submit" onclick=" return validateForm()">Login</button>
<br>
<button type="submit" onclick="Create()">Create</button>
</form>