php - Update Mysql value from an <a href> link uncaught referenceError -
i new php , mysql , having problems understanding why specific function update value within databse isnt working.
i want able change "0" int "1" when user clicks link. (i using value 0 / 1 track if user account active or not).
the link in question reads:
<?php $user = query("select * users id = ?", $_session["id"]); //check see if user active or not if ($user [0]['active'] == 0) { printf("your account not active "); printf('<a href="#" onclick="activate();">click me</a>'); printf(" reactivate"); } //assuming have logged in want make active ?>
when click link console reports:
uncaught referenceerror: activate not defined
i have defined activate in separate functions.php file being loaded , has correct permissions. (i sure being loaded code above when define activate manually in code above error telling me cannot define 2 functions same name).
the functions.php section reads:
function activate() { require("../templates/activate_user.php"); exit; }
finally, activate_user.php reads:
<?php // configuration require("../includes/config.php"); query("update users set active = 1 id = ?", $_session["id"]); return false; ?>
i have searched , searched on how fix error, have not been able fix issue. guessing might related scope of activate, not sure right path.
any received, first venture php/mysql points welcome.
thanks;
andy
the onclick="activate();" javascript code. rest of code written in php. both won't work way.
Comments
Post a Comment