我试图通过按下按钮(创建)来调用这个php函数。
<?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);
?>
我在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);
?>
}
,这在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>