在 Joomla 目录中放置一个简单的可调用 php 脚本的位置 [英] Where to put a simple callable php script in Joomla directory

查看:16
本文介绍了在 Joomla 目录中放置一个简单的可调用 php 脚本的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些 Joomla HTML 内容,其中包含一个简单的 HTML 表单,其结果应该可用于简单的 PHP 脚本.

I have some Joomla HTML content which contains a simple HTML form which results should available to a simple PHP script.

基本上 HTML 表单如下所示:

Basically the HTML form looks like:

<form action="action.php" method="post">

问题是我可以/应该将我的 action.php 脚本放在 Joomla 项目目录中的什么位置

The question is where can/should I put my action.php script in the Joomla project directory to be

  1. 可调用我的表单操作
  2. 不会被 Joomla 更新覆盖

推荐答案

我建议为表单创建一个组件.您可能需要处理表单中的输入,并根据表单中的内容执行一些操作,并在出现错误等时返回表单.

I would recommend creating a component for forms. You probably need to handle the input in your form, and do some action based on what is in the form, and return the form if there are errors, etc.

制作组件的最简单方法:

Simplest way to make a component:

  • 在组件中添加一个文件夹:/components/com_whatever
  • 在文件夹 com_whatever 中添加 php 文件:whatever.php
  • 添加xml文件:whatever.xml

whatever.xml 的内容:

Content of whatever.xml:

<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2.0" method="upgrade">
    <name>Whatever</name>
    <version>1.0.0.0</version>
    <files folder="site">
        <filename>whatever.php</filename>
    </files>
    <administration>
    </administration>
</extension>

whatever.php 的内容:

Content of whatever.php:

<?php
defined('_JEXEC') or die;
echo "HELLOOOO";
// or rather some code handling your form data

前往 yoursite/administrator/index.php?option=com_installer&view=discover 安装组件

Install the component by going to yoursite/administrator/index.php?option=com_installer&view=discover

现在你可以从表单访问whatever.php,使用:

Now you can reach whatever.php from the form, using:

<form action="index.php?option=com_whatever" method="post">

在你的组件中有很多你可以而且可能应该做的事情,但这是最起码的.

There is lots of stuff you can and probably should do in your component, but this is the bare minimum.

PS:你可以安装一个表单组件,有很多.或者,您可以使用组件构建器来创建表单,然后您还可以使用管理工具来处理传入的数据.

PS: You could install a form component, there are lots. Alternatively you could use a component-builder to create your form, then you also get admin-tools to handle the incoming data.

这篇关于在 Joomla 目录中放置一个简单的可调用 php 脚本的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆