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()));
}

?>
4
  • 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. Commented Nov 6, 2021 at 11:50
  • can you please write an example code. Commented Nov 6, 2021 at 12:39
  • Does this answer your question? Sending data from JavaScript to PHP via XMLHttpRequest Commented Nov 6, 2021 at 12:56
  • sorry i don't fully understand. Commented Nov 6, 2021 at 15:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.