3

I have a login script that checks whether or not a user has logged in before simply using a value in a mysql database. 1 for previously logged in and 0 for never logged in before. Right now it re-directs to a different page based on the value.

if ($member['prev_log_in'] == 0)
    {
         header("location: ../accountSetUp.php");
    }
    else
    {
         header("location: ../dashboard.php");
    }

Rather than re-direct to a different page I would like it to still take the new user to the dashboard, but show a Modal from bootstrap with the new user info.

The regular protocol for loading a modal is by a user clicking a button or link like so: that calls the modal.

<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>

So, I'm not sure how you could call the modal to load from the php. Even if the modal loaded while still on the login page would be fine. I just want the php script to display the modal if the user has never logged in before. I just don't know how to do it. Any thoughts would be great! Thank you.

2
  • Do you want to open the dashboard.php in modal? Commented Jun 28, 2013 at 4:14
  • No, I want the modal to show up with information about the new account. Just like a normal modal. Commented Jun 28, 2013 at 4:17

1 Answer 1

4

Try this:

if ($member['prev_log_in'] == 0){
    header("location: ../accountSetUp.php");
}else{
    echo "<script>jQuery(document).ready(function($) {
        $('#my-modal').modal(options)
    });</script>";
}

and <div id="my-modal"><iframe src="../dasboard.php"></div>

EDIT:

If you want to only open automatically the bootstrap modal when user enter to dashboard you can only put these lines in dashboard.php:

 <script>
 jQuery(document).ready(function($) {
             $('#my-modal').modal(options)
 });
 </script>

RE-EDIT:

Ok: If it was not logged in before:

PUT These lines in dashboard.php

if ($member['prev_log_in'] == 0){
    echo "<script>jQuery(document).ready(function($) {
        $('#my-modal').modal(options)
    });</script>";
}else{
    echo "You were logged in";
}

and <div id="my-modal"><iframe src="../accountSetUp.php"></div>

I hope this will help you!

Sign up to request clarification or add additional context in comments.

9 Comments

Just in case this does work. (i'm sure it will) my question was for Never Logged in "0" to have the modal displayed. You have it the other way, Can you just switch that around so I can accept your answer? Just to keep the stack overflow rules satisfied :)
Ok, would you put the <div id="my-modal"> within the login script page or on the login page? I tried it with the login script page and it seems to just stop the login script.
You must put in in dashboard.php, because in this page the modal appears. You must put the PHP lines in dashboard.php because you want to have in the background of modal, the dashboard.php page... @user2371301
So from Google Chromes Console I receive this error Uncaught ReferenceError: jQuery is not defined login-exec.php:1 My script for logging in is in a separate folder. The login process just stops and it displays a blank white page. With this code.
Have you put these lines in dashboard.php?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.