How to use php pages in Joomla? - php

I have 2 php pages, form.php and results.php. The form accepts user data and send to the database with mysql query, the results page retrieves the data for display.
I have installed Joomla as my CMS and it is connected with the database in which the form data is also stored.
How can i use these two pages in joomla?

You are better off developing a component for Joomla as that is the correct way to extend the functionality. Take a look at http://www.component-creator.com it can write all the code for you.

You can place these two pages into your web root directory & those will work.
If you want to use configurations defined for Joomla, just include those files into your PHP files.

If you want to place your form within a Joomla article, I would suggest using a form builder extension - there are quite a few in the Joomla extensions directory: http://extensions.joomla.org/extensions/contacts-and-feedback/forms
Using an extension like this will allow you to create your form in the Joomla admin area, publish it to your site, and then accept submissions which could then be emailed to you or viewed in the admin area.

Related

Wordpress admin plugin to save hidden input data to database

I am creating a Wordpress plugin for the admin area. It needs to set options and write to a file and database based on the options that are saved.
I have tried creating a "Create File" button which sends POST data back to itself. I now need to create a file and add a column to the database based on a hidden boolean filed.
I'm struggling because I can't do what I want because the form needs to have a different action. Any advice on how to so this?
What a different action? Without any code examples that show what you're doing and what exactly is not working, we only can imagine and give you general info. In Wordpress, you don't have to care about naked url options cause the core will do this for you. Its enough to register the required hooks, read the passed data here and do what is required with them. Simple storing settings wouldn't require to extend the database scheme, since Wordpress already have a table for this. You could use the Wordpress functions here.
See the article of the Wordpress developers page: https://codex.wordpress.org/Creating_Options_Pages
Using the hooks, its no big deal to create a file too. Simple write your PHP code after saving the settings in the database. How you concretely do this depends on the requirements: Is the data passed as form field? Is it fetched from an external source (like api)? Depending on the requirements this should be done with relatively less work using a search engine, cause enough sample codes exists for those scenarios.

Using PHP in Joomla Template

I'm developing a site using joomla template. I want to create a registration form & I design it with html in a Joomla Article. For data passing to db I have created a PHP file. But I have a problem in submitting data. I gave form action="php file name" & I save the PHP file in index path. But system is not working. Please tell me where I need to save that PHP file & how to link my joomla article & PHP file ???
Create a custom file upload component and upload your php files. Create a menu item for your component and assign a PHP file to menu you want to show your registration form on and finally at front-end include PHP file in your view.
Create a folder inside plugins in main directory.
Name it whatever you like, lets say, "customplugin". Put your form handling file in that.
Give the absolute path of this file in the form action URL.
This should work. Also, kindly check if the form tags are coming correctly in the article.
As others are saying, you are actually not using the Joomla CMS properly, but anything and everything is possible...
Mistakes are always forgivable, if one has the courage to admit them.
-- Bruce Lee

how to create a multipage website

how can I develop a multipage website?
should I develop all other linked pages in same way I created the homepage?
I am intending to develop a PHP website for a store and I wanna link each products to their individual pages. but since there are lots of products its kinda tedious to create individual pages each product.
SO Instead of creating many different pages for each product can I create one dynamically changing page and use it for all the product links?I mean can I create a single page whose basic layout will always remain the same but only few content will change in accordance to the selected product.
Yes, you can do that; its very common to create a page that dynamically changes.
For example, you can create a php file that takes care of the header portion of the site, then simply call it within your index.php page as so:
<? show_header(); ?>
Take a look at this website to get started!
http://www.techiwarehouse.com/engine/d3bf2317/Building-Dynamic-Web-Pages-with-PHP
The site i provided is great to start playing with PHP, it provides good information with easy to follow steps.
Another great resource is the IBM PHP PDF:
http://www.ibm.com/developerworks/linux/tutorials/l-php/l-php-pdf.pdf
Finally my personal favorite, "Practical PHP & MySQL" PDF:
http://utopia.duth.gr/~stavtran/vivlia/PHP_and_MySQL.pdf
Its also worth noting that there are Content Management Systems out there (CMS) such as Joomla, Worpress which are very easy and powerful, a lot of these CMS's allow for plugins which will make your life so much easier. If your goal is to simply have a solid working e-commerce website that sells products and you don't really wish to do hardcore php,mysql,javascript,css,html,jquery coding ;-)
Content Management Systems
http://wordpress.org/
http://www.joomla.org/
You can implement a single page, lets call it product.php. Then you can use theGET method to dynamically call the page. It would look like this product.php?id=1 where id=1 is the primary key of the product in a MySQL table. And you could fetch various products just changing the id in url.
You can create multipage PHP website using following method:
1) Create a folder and name it “my_first_php_website”.
2) Create following folders in your “my_first_php_website” folder.
“images”, “includes”
3) Create following folders in “includes” folder.
“css”, “js”
4) Create following files in “my_first_php_website” folder.
-> “index.php”, “header.php”, “footer.php”, “sidebar.php”, “nav.php”, “404.php”, “about.php”, “functions.php”
Create following file in “css” folder.
-> “style.css”
Put your website logo in “images” folder.
-> “my_website_logo.png”
5) Now follow step by step tutorial to create your first website using PHP.
Source: Web Designer Tricks

run a function on each page

My codeigniter app is multilingual and I want to redirect users to their pages, by checking IP address.
I should check it at the top of all pages (i know i can set a session or cookie, but i want to check it on all pages); before any views or other.
Where should i put my code (function)? on Startup file or Loader? or create an extension or plugin and load it on Startup? if it can be done by an extension or plugin, how can I create it? (i've searched, but didn't find a useful tutorial)
Thanks.
If you're using a main front controller you can put your code in there. But a better way to do it would be to use CodeIgniters built in functionality to extend the core - hooks!
http://codeigniter.com/user_guide/general/hooks.html
Just select the point you want your script to be activated and take it from there.

Custom php code in Joomla page

I'm trying to change the source of a table in a Joomla 1.5.9 page from hardcoded html in the page to getting the information from a SQL database. What is the proper way to do this? Create a new model or component and somehow use that in the page?
I found these:
http://docs.joomla.org/Tutorial:How_to_use_the_database_classes_in_your_script
http://docs.joomla.org/How_to_use_the_database_classes_in_your_script
But I'm not sure where to write the php code and how to access it in the page. If somebody could point me to a basic tutorial for custom php or whatever it's called, I'm new to webb development, I'd be happy.
You can use the Jumi extension to add custom PHP code to a Joomla page or module.
You Can install The Php Pages Component in joomla 1.5 .Where you can write your custom php code in joomla .
Also using this Php Pages Component you can Also write the query in the Php Code Itself.
So That you can extract the data from the database.

Categories