0

this is a stupid code that should use sessions to disable or not a button. the page load properly, but the function "fun()" is never called even the button click. Why?

<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>

thanks for the help..

Dingo
  • 21
  • 3

0 Answers0