0
 <script>
 function onProgress(currentTime) {
    if(currentTime > 20) {
      console.log("the video reached 20 seconds!");
      <?php
        include("ayar.php");
        $mysqli = connection();
        $email = $_POST['email'];
        $hak = '1';
        $sorgu = mysqli_query($mysqli,"INSERT INTO gift_chance(email,hak) values ('$email', '$hak')");
      ?>
    }
  }
  </script>

This kind of usage is it possible ? If currentTime is bigger than given seconds, i want to execute the php code.

Ozge
  • 15
  • 5
  • 3
    Does this answer your question? [Call php function from JavaScript](https://stackoverflow.com/questions/7165395/call-php-function-from-javascript) Have a look at the second answer – Wendelin Nov 20 '19 at 22:50
  • That's not how it works; PHP runs on the server, and simply outputs everything outside PHP tags as-is. PHP doesn't know or care that the mysql_query is surrounded by a JS function. You need AJAX/fetch() to run server-side code from JS. (the code you posted will run the query immediately, then send an essentially empty `if` block to the browser) –  Nov 20 '19 at 22:54

0 Answers0