Hello, currently throughout my entire site, I am using a basic, include_once in the php, to redirect the user to another page (msgToUser.php), and display the desired message: For example on my profile page I have several instances of the following, whereby the $msgToUser variable may be different depending on certain things:

$msgToUser = "You and $firstname are NOT friends, but a friend request was sent on $request_time <br />";
include_once('msgToUser.php');
exit();

Or on an another page (activation.php) I may have:

if ($doublecheck > 0) { 
    $msgToUser = "Your account has been activated! <br /><br />
     You may now login.";
    include 'msgToUser.php'; 
    exit();
} 

What I want to be able to do, is replace all of these redirects with a simple jquery popup, particularly the Jquery Modal Dialog confirmation box (in case I want to include a link in the popup). I already have the jquery library on my site, along with the jquery-ui and jquery-css. Is there a simple way to do this by adding a little script to either the initial page or to the msgToUser.php page? I am sort of new to using Jquery... Also would it be wise to keep the msgToUser.php page in place (somehow in conjunction with the jquery popup), in case someone does not have a js/jquery enabled browser?

    even if you changed the content of msgToUser.php there's is still the issue with exit() after it, so i think you need to some more fundamental redesign.

      A few options:
      Remove the php include and exit while amending this..
      Add your javascript functions to put up the message boxes
      (I couldn't say what you need to do to make the modal item work - check the documentation on the plugin)

      Note there's no such thing as a jquery enabled browser - jquery is javascript - it's a library of code to make working with javascript easier

      So once you have it all working with javascript put back the php and as Dagon points out you need to rethink your logic flow:
      if the include runs some other code, conditional on what the actual user status is, then that will run regardless of your javascript

      Clearly you should rethink it before doing any rebuilding

      Note including another script is not a redirect as such - a redirect is when you bounce the user to a new page or a new script, so while the end result can appear the same, different things are happening

      Why not just leave it as it is, forget the modal stuff - show the message on the page via PHP but don't do any exit - then if there is a message to show don't run the next piece of code that you are currently avoiding by doing an exit

      (once you have a simpler logic path, adding a javascript solution should be easier)

        The reason I do exit(), is because the $msgToUser is on the profile page for example.

        So whenever you click on someone's picture, it takes you to: http://localhost/MySite/profile.php?id=110

        So there is a check to see if that member is your friend or not. And if I click on a member who is not (yet) my friend, I want to send him to msgToUser.php (which has it's own html) and echo something like "You and $thismember are not yet friends, Click Here to Send A Friend Request"... So I want to exit the page, before that member's profile is run... Because if they are not yet friends, I don't want to be able to view the other guy's profile.

        Now that I think about it, I may be better off just disregarding msgToUser.php and just having a jquery pop-up display the message....

        Or is there a way to just make $msgToUser.php come up as sort of like a smaller sized pop-up window, on top of the current window (without proceeding to profile.php)?

          if you want your message to appear over the main window use javascript

          I'd have the message logic entirely separated from the control logic that sets what the user can access

          you can choose to run a piece of code on an 'if /else' basis - it might be less restricting than your way of running another script followed by an exit of the current script

            Perhaps something like

            $target = new User((int) $_GET['id']);
            if ($user->isFriendsWith($target))
            {
            	$content = $target->getProfile();
            }
            else
            {
            	$content = $target->getFriendRequestLink();
            }
            
            
            echo
            '<div id="content">
            	'.$content.'
            </div>';
            require 'page_footer.php';
            
              Write a Reply...