繁体   English   中英

HTML在其他文件中调用PHP函数

[英]HTML call PHP Funtion in other File

我想在HTML按钮之外的其他文件中调用PHP函数。

我被困在这里

HTML档案:

<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文件:

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

如何从HTML文件中调用deleteFotogalerie()?

你不能

HTML是一种客户端标记语言,而PHP是一种服务器端语言。 在HTML中,您只能直接调用JS函数。

您需要做的是使API执行一些特定的必需任务,并从HTML页面调用此API作为XHR来执行任务。

一种使用jQuery AJAX做到这一点的简单方法: http : //api.jquery.com/jquery.ajax/

像这样调用它: <?php deleteFotogalerie() ?>

像这样添加该文件,然后再执行此操作

<?php
  include 'File1.php';
?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM