0

I would like to call a PHP Function in a other file than the HTML Button.

I'm stuck here

HTML File:

<form method="POST" action="../php/appl_functions.php" onsubmit="return confirm('Sind Sie sicher?');">
     <button type="submit" class="btn btn-danger" name="delete">Galerie Löschen</button>
</form>

PHP File:

function deleteFotogalerie(){
     db_delete_fotogalerie(getSessionValue('fotogalerie_id'));
     return runTemplate("../templates/fotoalben.htm.php");
}

How can I call deleteFotogalerie() From the HTML file?!

Alok Patel
  • 7,842
  • 5
  • 31
  • 47
Mr. Toast
  • 941
  • 3
  • 11
  • 27
  • you need to use AJAX. – Barmar Jun 04 '16 at 11:07
  • Possible duplicate of [how can call function of one php file from another php file and pass parameter to it?](http://stackoverflow.com/questions/8104998/how-can-call-function-of-one-php-file-from-another-php-file-and-pass-parameter-t) – Ani Menon Jun 04 '16 at 11:15

2 Answers2

0

You can't.

HTML is a client side markup language, where as PHP is server side language. Within HTML you can only call JS functions directly.

What you need to do is make API which perform some specific required task and call this API as XHR from HTML page to perform task.

One easy way to do this using jQuery AJAX : http://api.jquery.com/jquery.ajax/

Alok Patel
  • 7,842
  • 5
  • 31
  • 47
0

Call it like this: <?php deleteFotogalerie() ?>

Add that file before you do this, like this

<?php
  include 'File1.php';
?>
Emily
  • 96
  • 1
  • 11