我尝试在我的 JavaScript 代码中嵌入 PHP,看看会发生什么。实际上什么也没发生。有人可以建议我这样做吗?
<head>
<script>
function myF() {
n=document.getElementById("name").value
r=document.getElementById("reason").value
<?php
$f = fopen("VisitorLog.txt", "w");
fwrite($f, "Profile viewed on "+Date()+" by "+n+" Reason= "+r);
fclose($f);
?>
document.getElementById("name").disabled=true;
document.getElementById("reason").disabled=true;
document.getElementById("register").disabled=true;
document.getElementById("link").style.display="inline";
alert("You have successfully registered.");
}
</script>
</head>
我对所有这些东西都很陌生,还在学习。请尝试用更简单的术语解释。:P