Mon. - Fri. 9 am - 5 pm Ask a Question
Remember me

include() in PHP Scripts section not working

3 weeks 9 hours 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

3 weeks 8 hours ago #2

  • Vyacheslav's Avatar
  • Vyacheslav
  • Posts: 28391
Hello,
Thank you for contacting us

Send us a link to page with problem.

Regards,
Vyacheslav, Balbooa.com

3 weeks 8 hours 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.

3 weeks 7 hours ago #4

  • Vyacheslav's Avatar
  • Vyacheslav
  • Posts: 28391
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

3 weeks 5 hours ago #5

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

2 weeks 4 days 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.

2 weeks 4 days 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