Remember me

include() in PHP Scripts section not working

7 months 2 weeks ago #1

  • Paul's Avatar
  • Paul
  • Posts: 8
Hi,

We are trying to include a separate PHP script upon form submission. We've done this successfully with your module on other websites running Joomla 3, but this website is running Joomla 4 and we can't get it to run the external file.

This is what we've got:
include('/customcode/bookingemail.php');

We've stripped back the external file for test purposes and it just has a simple mail() command in.

We've checked the path to the external file is correct, and that it has 755 permissions.

Do you have any advice please?

Thanks,

Chris

7 months 2 weeks ago #2

  • Viacheslav's Avatar
  • Viacheslav
  • Posts: 28858
Hello,
Thank you for contacting us

Send us a link to page with problem.

Regards,
Vyacheslav, Balbooa.com

7 months 2 weeks ago #3

  • Paul's Avatar
  • Paul
  • Posts: 8
Hi,

Thanks for replying.

The website isn't live yet so I'm not able to. I can give you a login if you have somewhere private I can send it to?

Thanks.

7 months 2 weeks ago #4

  • Viacheslav's Avatar
  • Viacheslav
  • Posts: 28858
Send us a link to page with problem.
Send us Joomla admin access via our contact form.
support.balbooa.com/contact-us

Regards,
Vyacheslav, Balbooa.com

7 months 2 weeks ago #5

  • Paul's Avatar
  • Paul
  • Posts: 8
Thanks, I have sent across the info.

7 months 1 week ago #6

  • Paul's Avatar
  • Paul
  • Posts: 8
I believe I may have fixed this. Instead of a straight PHP include, I've done the following:
define('_JEXEC', 1);    
use Joomla\CMS\Factory;
define('JPATH_BASE', realpath(dirname(__FILE__) . '/..'));
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
error_reporting(E_ALL);
ini_set('display_errors', 1);
$crlf		= PHP_EOL;

require_once JPATH_BASE . '/customcode/bookingemail.php';

Something to be aware of for anyone else using Joomla 4.

7 months 1 week ago #7

  • Paul's Avatar
  • Paul
  • Posts: 8
I've narrowed it down further to just the following in the custom PHP script section of the form.
define('_JEXEC', 1);    
use Joomla\CMS\Factory;
define('JPATH_BASE', realpath(dirname(__FILE__) . '/..'));
require_once JPATH_BASE . '/customcode/bookingemail.php';
Powered by Kunena Forum