I need to trigger a Bootstrap modal if a PHP GET url is set but I don't know how to.
The PHP code look's like this:
<?php
if ($_GET['activate']) {
$activate = $_GET['activate'];
mysql_query("UPDATE `users` SET `active` = 1 WHERE `email_code` = '$activate'");
}
?>
After the mysql query but still in the if I need the modal to trigger. I've considered json but don't know enough to create my own code. The javascript to show the modal is this line:
$('#myModal').modal('show')
How would I translate that to work with my PHP trigger?
Add a variable that checks the state,
$show_modal = false;
And in your get set it to true,
if ($_GET['activate']) {
$activate = $_GET['activate'];
mysql_query("UPDATE `users` SET `active` = 1 WHERE `email_code` = '$activate'");
$show_modal = true;
}
Now in your html :
<?php if($show_modal):?>
<script> $('#myModal').modal('show');</script>
<?php endif;?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With