Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9005419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:08:23+00:00 2026-06-16T01:08:23+00:00

This php function currently redirects the user to another page if they aren’t logged

  • 0

This php function currently redirects the user to another page if they aren’t logged in

if(!isset($_SESSION['SESS_USER_ID']) || (trim($_SESSION['SESS_USER_ID']) == '')){
header("location: login_failed.html");
exit();
} 

How can I change the function so that instead of redirecting the user it does the following:

  • Triggers the javascript function: loginFailed();
  • Prevents specific iframes which are preloaded from launching (these require a user to be logged in, and are currently opening as empty iframes if they’re not logged in). I’ve included the script for this below. Alternatively, preventing iframes from launching which have a specific class or data-fancybox-type, or those which require !isset($_SESSION['SESS_USER_ID']).

The functions which I want to trigger/prevent

function loginFailed() {
    $().toastmessage('showToast', {
        text: 'Log In Failed<br/><br/>Please check your username and password',
        sticky: false,
        position: 'top-center',
        type: 'message',
        closeText: '',
        close: function () { console.log("toast is closed ...") }
    });
} 
$(function () {
    $(".fancybox").fancybox({
      preload: true,
    });
    $(".fancybox").eq(0).trigger('click');
});   

I’ve tried:

echo "<script>loginFailed();</script>";
echo "<script type="text/javascript">loginFailed();</script>";
echo "<script type="text/javascript">loginFailed;</script>";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:08:24+00:00Added an answer on June 16, 2026 at 1:08 am

    I combined @hellohellosharp’s suggestion with a solution which was given to me by @willoller for another problem and figured it out 🙂

    Add this to the php:

    $logged_in = (isset($_SESSION['SESS_USER_ID']));
    

    Add this to the javascript:

    <?php if ($logged_in) : ?>
        <a class="fancybox" data-fancybox-type="iframe" href="iframe1.html"></a>
    <?php else : ?>  
         loginFailed();
    <?php endif; ?>
    

    I’m also using this to change the menu options based on whether or not a user’s logged in.

    Just a reminder – this uses ISSET to determine what javascript should show, but it only changes the user’s experience and doesn’t provide any security.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently call a function to filter some HTML in PHP like this FilterHTML($string)
Currently I use the following for checking is a user is logged in: function
I have this function to unlock a list the user is currently editing: function
I want to run this PHP function -- $querystring_arr='maxResults=50&startIndex=50&sort=date'; $str=preg_replace((&startIndex=)?[0-9]*(&)?,&startIndex=.$sindex.&,$querystring_arr); When I print $str
How can I this PHP function include in jquery .html? PHP function: function trim_text($string,
this is function.php of a wordpress theme that NOD32 says this code have a
i'm referring this address for function olLiTree PHP function that creates a nested ul
i have this strange problem with the PHP function CTYPE_ALNUM if i do: PHP:
How do you translate this perl subroutine into a PHP function? sub disagreement {
I have this part of code in my functions.php: function cc_admin_enqueue_scripts($hook) { $file_dir=get_bloginfo('template_directory'); wp_enqueue_script('media-upload');

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.