0

I need php function that works after html button is visible. When you click twice in succession with these codes, the sonsion is called twice.

<button id="btnsubmit" name="submit" <?php echo isset($_POST["btnsubmit"]) ? "disabled" : "";?>>submit</button>

<?php

if (isset($_POST['submit'])) { 

date();

}

function date(){
print(date('Y-m-d H:i:s', time()));
}

?>
  • The problem here is that PHP would have no idea that the button is visible or not on the client side. What you need to do is to tell PHP that the button is visible by sending an Ajax request using Javascript or any other mechanism to the server so PHP function can then be called. – Rain Nov 06 '21 at 11:50
  • can you please write an example code. – mehmet çece Nov 06 '21 at 12:39
  • Does this answer your question? [Sending data from JavaScript to PHP via XMLHttpRequest](https://stackoverflow.com/questions/43098620/sending-data-from-javascript-to-php-via-xmlhttprequest) – Rain Nov 06 '21 at 12:56
  • sorry i don't fully understand. – mehmet çece Nov 06 '21 at 15:01

0 Answers0