简体   繁体   English

创建文章

[英]Create an Article

I would like to understand how to create Articles using PHP.我想了解如何使用 PHP 创建文章。 As today I use Fabrik to collect info using form, but i need to create in authomatic way a Joomla Article based on those data.就像今天一样,我使用 Fabrik 使用表单收集信息,但我需要根据这些数据以自动方式创建 Joomla 文章。

I'm looking for a solution (if is possible) based on PHP that will be executed when user submit the form.我正在寻找基于 PHP 的解决方案(如果可能),该解决方案将在用户提交表单时执行。

To run PHP code or a pre-written script following the submission of a Fabrik form, use the PHP Form Plugin .要在提交 Fabrik 表单后运行 PHP 代码或预先编写的脚本,请使用PHP 表单插件 Scripts that run via the PHP Form plugin are within the scope of the Joomla application, so you could definitely automate the creation of an article (by way of the com_content component).通过 PHP 表单插件运行的脚本在 Joomla 应用程序的范围内,因此您绝对可以自动创建文章(通过 com_content 组件)。

If you have questions about using the plugin, your best bet would be asking on the Fabrik Forums如果您对使用该插件有疑问,最好的办法是在Fabrik 论坛上提问

You would, preferably, save the article in a database (MySQL, maybe) then you would using the form (using METHOD="POST") send the results and extract them (using $_POST['* name of input']) and then save that variable into the MySQL database.您最好将文章保存在数据库(可能是 MySQL)中,然后您将使用表单(使用 METHOD="POST")发送结果并提取它们(使用 $_POST['* name of input'])和然后将该变量保存到 MySQL 数据库中。

<form action="?article=submit" method="POST">
<input type="text" name="title"/>
<input type="submit"/>
</form>

<?php
if($_GET['article'] == "submit"){
if(!empty($_POST['title'])){
mysql_query("INSERT INTO article (title)VALUES ('".$_POST['title']."')")or die(mysql_error());
}

}
?>

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

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