I recently installed joomla 3x with 'simple file upload' module. I modified the module php script so that a user can input variables such as $title, $artist, etc. within a form. The form post the variables to another php files (make-page.php) that renders the inputs into a nice html page ... that works fine.
But when I use defined('_JEXEC') or die('Restricted access'); at the top of the make-page.php to prevent a non logged in user to access and run the script, the logged in user can no longer access the script him/her self ?
I have looked at the answers for similar _JEXEC situations, but no luck so far... Can somebody point me in a good direction?
Thanks many time.
_JEXEC
is not a function to check if a user is logged in or not.
To perform this check, you can use the following:
$user = JFactory::getUser();
if (!$user->guest)
{
// Run the PHP script
}
else
{
echo 'Sorry, you must be logged in';
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.