1

I am trying to write a php file to process a form submission.
Here is the code I have so far:

<?php


 define('_JEXEC', 1);

if (file_exists(dirname(__FILE__) . '/defines.php')) {
    include_once dirname(__FILE__) . '/defines.php';
}

if (!defined('_JDEFINES')) {
    define('JPATH_BASE', dirname(__FILE__));
    require_once JPATH_BASE.'/includes/defines.php';
}

require_once JPATH_BASE.'/includes/framework.php';

//The following two files do not exist in my Joomla installation, is that normal?  
//require_once JPATH_BASE.'/includes/helper.php';
//require_once JPATH_BASE.'/includes/toolbar.php'; 



//This here is throwing an exception 
 $app = JFactory::getApplication();

//$app->redirect('another page in my site');
?>

I am getting the following error:

Error displaying the error page: Application Instantiation Error: Application Instantiation Error

Every other page in the website is working correctly, I have checked the configuration file and all the database settings are there.

I also tried repairing the DB through joomla back end and through phpmyadmin and that didn't change anything.

any ideas what have I done wrong here?

Thank you

  • Any reason why you're using a PHP file rather than a module for the form? – Lodder Mar 8 '17 at 14:19
  • @lodder, I am new to joomla so I might be doing something wrong. In my case the redirection page depends on the form content plus values from a third party remote server. I was planning to use the third party API in my php page and then based on that redirect the user. – Moha the almighty camel Mar 8 '17 at 14:23
1

You haven't included the JFactory so to use Joomla's Database Class.

After requiring the framework add:

require_once( JPATH_BASE .'/libraries/joomla/factory.php' );

The following are not part of Joomla 3 version - it's normal that you don't see such files. How did they reach to your code?

//The following two files do not exist in my Joomla installation, is that normal?  
//require_once JPATH_BASE.'/includes/helper.php';
//require_once JPATH_BASE.'/includes/toolbar.php';
  • About the two other files, I was not sure what should I add to include the joomla API. And I kept trying various things I found on the forums. – Moha the almighty camel Mar 8 '17 at 22:08
  • no exception anymore. but the redirect command is doing nothing. and Yes, I uncommented it :D – Moha the almighty camel Mar 8 '17 at 22:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.