在哪里将简单的可调用php脚本放在Joomla目录中 [英] Where to put a simple callable php script in Joomla directory

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

问题描述

我有一些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. 可调用我的form action
  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
  • 添加php文件:com_whatever文件夹中的what.php
  • 添加xml文件:what.xml

what.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>

what.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

现在,您可以使用以下方法从表单中访问what.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.

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

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