harry1 Posted October 31, 2019 Share Posted October 31, 2019 Hi all Hoping for some guidance as to what I am doing wrong. In my _output I've got: echo file_get_contents(__DIR__ . '/data.php'); Then in that data.php, HTML + JS works perfectly however if I try do PHP from within the data.php it doesn't appear. <?php if (!defined("WHMCS")) { die("This file cannot be accessed directly"); } $clientImport = "test"; print "test"; ?> <html> <head> </head> Domain: <input type="text" id="domain"><br><br> <?echo $clientImport; print "test";?> <body> The HTML input box for domain is working, however none of the PHP print outs are working. Interestingly, though, the first if statement works as it doesn't allow me to browse that data.php file directly. It results in the die error, so working as intended. Hoping someone can clarify what I'm doing wrong? Thanks. 0 Quote Link to comment Share on other sites More sharing options...
harry1 Posted October 31, 2019 Author Share Posted October 31, 2019 Sorry, in particular, what I'm trying to achieve is to get a parameter from the URL $var = $_GET['var']; 0 Quote Link to comment Share on other sites More sharing options...
harry1 Posted November 1, 2019 Author Share Posted November 1, 2019 (edited) I think my question is confusing - I'll try make a clearer explanation. I'm making an Addon Module and the core use of it is in the admin output function. function addontest_output() { echo file_get_contents(__DIR__ . '/data.php'); } I then have data.php. I'm trying to use PHP from within this data.php with no success. However, the first line works as if I browse the file directly, I get the "This file cannot be accessed directly" error. No PHP used in the data.php works, except for the first if statement. <?php $test = "Test"; if (!defined("WHMCS")) { die("This file cannot be accessed directly"); } ?> <html> <head> </head> <body> <p>Testing</p> <?php print "Test"; echo $test; ?> </body> </html> Hopefully this is more clear? Cheers Edited November 1, 2019 by harry1 0 Quote Link to comment Share on other sites More sharing options...
harry1 Posted November 1, 2019 Author Share Posted November 1, 2019 Ahh it was so simple! Just overlooking it for so long. I meant to include, not file_get_contents... silly mistake 🙂 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.