Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have this:
<input type="checkbox" onclick="windows.location.href='admin-dashboard.php?action=approveapp&id=
PHP
<?php echo $row['app_id']; ?>
'">

And this:
PHP
if (isset($_GET["id"]))
{
    $id = $_GET["id"];
    echo "ID: ".$id;
    if (isset($_GET["action"]))
    {
        $action = $_GET["action"];
        echo "ACTION: ".$action;
        switch ($action)
        {
            case "approveapp":
                $sql = "UPDATE tblapplications SET approved = 1 WHERE app_id = $id";
                echo $sql;
                mysqli_query($conn, $sql);
                break;
        }
    }
    else {
        $action = "";
    }
}
else {
    $id = "";
}


When the checkbox is clicked, it's supposed to perform some query to the database, but when I click on the checkbox, nothing happens. Am I missing something?
Posted
Updated 4-Oct-15 3:00am
v3
Comments
Do you see any error on browser console?

1 solution

Try to replace

JavaScript
windows.location.href


with

JavaScript
window.location.href


Just a small typo. You could have easily seen the issue in browser console while debugging. Please refer below for more details:
The powerful JavaScript Console within Chrome DevTools[^]
Discovering Windows Internet Explorer Developer Tools[^]
 
Share this answer
 
v2
Comments
kmllev 5-Oct-15 21:51pm    
I can't believe this, no error was popping up so I didn't notice it, you're a lifesaver thank you!
Palash Mondal_ 5-Oct-15 22:55pm    
You are welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900