Reputation: 3474
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.
Upvotes: 3
Views: 162
Reputation: 11271
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!
Upvotes: 4