这是一个愚蠢的代码,应该使用会话来禁用或不禁用按钮。页面加载正确,但即使单击按钮也不会调用函数“fun()”。为什么呢?
<html>
<head>
</head>
<body>
<?php
session_start();
if(isset($_SESSION['session']))
{
echo "<button type='submit' disabled'>button disabled</button>";
}
else
{
echo "<button type='submit' onclick='fun()'>button enabled</button>";
}
function fun(){
echo "sdagasdgasdg";
/*$host = "myhost";
$username = "myuser";
$password = "mypass";
$db_name = "mydb";
$tbl_name = "mytbl";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql = mysql_query("SELECT * FROM $tbl_name");
$row = mysql_fetch_array($sql);
$value = $row['column'];
$value++;
$sqlrefresh = mysql_query("UPDATE $tbl_name SET column = $value");
mysqli_close();*/
$_SESSION["session"] = "something";
}
?>
</body>
</html>
感谢您的帮助..