html:
<button type="button" class="btn btn-outline-danger btn-icon-text" id = "LOAD"> <i class="mdi mdi-upload btn-icon-prepend"></i>LOAD </button>
php:
<?php if (isset($_SESSION['LOAD'])) { exit(); } ?>
when i click the button, nothing happens. sorry i am really new to html and php. i have tried multiple other methods but none work 🙁
Advertisement
Answer
<button type="button" class="btn btn-outline-danger btn-icon-text" id = "LOAD"> <i class="mdi mdi-upload btn-icon-prepend"></i>LOAD </button>
That’s just a HTML code, so it will not trigger anything. You need little bit javascript.
Also remember, php loads before javascript. So you can’t trigger php with javascript if you don’t use AJAX or redirect etc.
<script> document.getElementById("LOAD").onclick = function(){ window.location.href = window.location.href+"?LOAD=1"; } </script>
If you add that javascript code, button will refresh the page and redirect the same page with GET parameter. You can control the GET parameter on the PHP side.
<?php if (isset($_GET['LOAD'])) { exit(); } ?>
It’s not efficient path but if you understand the mechanics, you can figure it out.
Research AJAX.