Show modal if not logged inI need an expample of jQuery Autocomplete returning id and name using ajaxBind a function to Twitter Bootstrap Modal CloseDisallow Twitter Bootstrap modal window from closingBootstrap modal appearing under backgroundselect only text input names from POSTClose Bootstrap ModalDisable click outside of bootstrap modal area to close modalSql special character to Html charactersGetting text from select option to modal bootstrapif(isset($_FILES)) Not working in PHP

Is it tax fraud for an individual to declare non-taxable revenue as taxable income? (US tax laws)

Why can't I see bouncing of a switch on an oscilloscope?

Arthur Somervell: 1000 Exercises - Meaning of this notation

How to write a macro that is braces sensitive?

Approximately how much travel time was saved by the opening of the Suez Canal in 1869?

Adding span tags within wp_list_pages list items

How much RAM could one put in a typical 80386 setup?

Email Account under attack (really) - anything I can do?

Are the number of citations and number of published articles the most important criteria for a tenure promotion?

Why does Kotter return in Welcome Back Kotter?

Fencing style for blades that can attack from a distance

How can bays and straits be determined in a procedurally generated map?

How is it possible to have an ability score that is less than 3?

Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

How do I create uniquely male characters?

To string or not to string

Why was the small council so happy for Tyrion to become the Master of Coin?

Why, historically, did Gödel think CH was false?

What's the point of deactivating Num Lock on login screens?

Can divisibility rules for digits be generalized to sum of digits

Why do falling prices hurt debtors?

Collect Fourier series terms

tikz: show 0 at the axis origin



Show modal if not logged in


I need an expample of jQuery Autocomplete returning id and name using ajaxBind a function to Twitter Bootstrap Modal CloseDisallow Twitter Bootstrap modal window from closingBootstrap modal appearing under backgroundselect only text input names from POSTClose Bootstrap ModalDisable click outside of bootstrap modal area to close modalSql special character to Html charactersGetting text from select option to modal bootstrapif(isset($_FILES)) Not working in PHP






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm trying to make a modal popup display allowing you to log in but only if you are not logged in.



I have tried many solutions but so far can only get the login to display in a new page.



Please see my code below



index.php



<?php 

require 'database_connection.php';

if (!isset($_SESSION["type"]))
echo "<script>$('#loginModal').modal('show');</script>";


require 'includes/header.php';
?>

***
***
if session type is
set code goes here
***
***

<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>


database_connection.php



<?php

$connect = new PDO('mysql:host=localhost;dbname=continental3', 'root', 'password');
session_start();

?>


What am I missing?



On a side note if there is an easier or better way of doing this I'm happy to change my approach



Any help would be greatly appreciated



** UPDATE**



<?php

require 'database_connection.php'; //checks session type is set or not
require 'includes/header.php'; // Loads css and js files

if (!isset($_SESSION["type"])) //session check


echo '<script>$(document).ready(function()$("#loginModal").modal("show"););</script>';
//open modal

require 'function.php';
require 'includes/navbar.php';

?>


The above code shows the modal as expected but only after the page has loaded. removing the document ready function the modal does not load but the rest of the page loads and displays (presumably because I do not use the else condition. When using the else condition as seen below nothing loads.



<?php

require 'database_connection.php';
require 'includes/header.php';

if (!isset($_SESSION["type"])) ?>


echo '<script>$(document).ready(function()$("#loginModal").modal("show"););</script>';
<?php else

require 'function.php';
require 'includes/navbar.php';

?>

***
***
if session type is
set code goes here
***
***

<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>
<?php #close else ?>









share|improve this question
























  • You didn't start a session with session_start();

    – user1334621
    Mar 21 at 23:56












  • Sorry, @catcon I appreciate your answer, this is included in another file. I will amend my question to reflect this

    – Andy Roe
    Mar 22 at 0:00











  • Thanks for your input Emma, this made no difference though

    – Andy Roe
    Mar 22 at 8:01

















0















I'm trying to make a modal popup display allowing you to log in but only if you are not logged in.



I have tried many solutions but so far can only get the login to display in a new page.



Please see my code below



index.php



<?php 

require 'database_connection.php';

if (!isset($_SESSION["type"]))
echo "<script>$('#loginModal').modal('show');</script>";


require 'includes/header.php';
?>

***
***
if session type is
set code goes here
***
***

<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>


database_connection.php



<?php

$connect = new PDO('mysql:host=localhost;dbname=continental3', 'root', 'password');
session_start();

?>


What am I missing?



On a side note if there is an easier or better way of doing this I'm happy to change my approach



Any help would be greatly appreciated



** UPDATE**



<?php

require 'database_connection.php'; //checks session type is set or not
require 'includes/header.php'; // Loads css and js files

if (!isset($_SESSION["type"])) //session check


echo '<script>$(document).ready(function()$("#loginModal").modal("show"););</script>';
//open modal

require 'function.php';
require 'includes/navbar.php';

?>


The above code shows the modal as expected but only after the page has loaded. removing the document ready function the modal does not load but the rest of the page loads and displays (presumably because I do not use the else condition. When using the else condition as seen below nothing loads.



<?php

require 'database_connection.php';
require 'includes/header.php';

if (!isset($_SESSION["type"])) ?>


echo '<script>$(document).ready(function()$("#loginModal").modal("show"););</script>';
<?php else

require 'function.php';
require 'includes/navbar.php';

?>

***
***
if session type is
set code goes here
***
***

<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>
<?php #close else ?>









share|improve this question
























  • You didn't start a session with session_start();

    – user1334621
    Mar 21 at 23:56












  • Sorry, @catcon I appreciate your answer, this is included in another file. I will amend my question to reflect this

    – Andy Roe
    Mar 22 at 0:00











  • Thanks for your input Emma, this made no difference though

    – Andy Roe
    Mar 22 at 8:01













0












0








0








I'm trying to make a modal popup display allowing you to log in but only if you are not logged in.



I have tried many solutions but so far can only get the login to display in a new page.



Please see my code below



index.php



<?php 

require 'database_connection.php';

if (!isset($_SESSION["type"]))
echo "<script>$('#loginModal').modal('show');</script>";


require 'includes/header.php';
?>

***
***
if session type is
set code goes here
***
***

<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>


database_connection.php



<?php

$connect = new PDO('mysql:host=localhost;dbname=continental3', 'root', 'password');
session_start();

?>


What am I missing?



On a side note if there is an easier or better way of doing this I'm happy to change my approach



Any help would be greatly appreciated



** UPDATE**



<?php

require 'database_connection.php'; //checks session type is set or not
require 'includes/header.php'; // Loads css and js files

if (!isset($_SESSION["type"])) //session check


echo '<script>$(document).ready(function()$("#loginModal").modal("show"););</script>';
//open modal

require 'function.php';
require 'includes/navbar.php';

?>


The above code shows the modal as expected but only after the page has loaded. removing the document ready function the modal does not load but the rest of the page loads and displays (presumably because I do not use the else condition. When using the else condition as seen below nothing loads.



<?php

require 'database_connection.php';
require 'includes/header.php';

if (!isset($_SESSION["type"])) ?>


echo '<script>$(document).ready(function()$("#loginModal").modal("show"););</script>';
<?php else

require 'function.php';
require 'includes/navbar.php';

?>

***
***
if session type is
set code goes here
***
***

<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>
<?php #close else ?>









share|improve this question
















I'm trying to make a modal popup display allowing you to log in but only if you are not logged in.



I have tried many solutions but so far can only get the login to display in a new page.



Please see my code below



index.php



<?php 

require 'database_connection.php';

if (!isset($_SESSION["type"]))
echo "<script>$('#loginModal').modal('show');</script>";


require 'includes/header.php';
?>

***
***
if session type is
set code goes here
***
***

<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>


database_connection.php



<?php

$connect = new PDO('mysql:host=localhost;dbname=continental3', 'root', 'password');
session_start();

?>


What am I missing?



On a side note if there is an easier or better way of doing this I'm happy to change my approach



Any help would be greatly appreciated



** UPDATE**



<?php

require 'database_connection.php'; //checks session type is set or not
require 'includes/header.php'; // Loads css and js files

if (!isset($_SESSION["type"])) //session check


echo '<script>$(document).ready(function()$("#loginModal").modal("show"););</script>';
//open modal

require 'function.php';
require 'includes/navbar.php';

?>


The above code shows the modal as expected but only after the page has loaded. removing the document ready function the modal does not load but the rest of the page loads and displays (presumably because I do not use the else condition. When using the else condition as seen below nothing loads.



<?php

require 'database_connection.php';
require 'includes/header.php';

if (!isset($_SESSION["type"])) ?>


echo '<script>$(document).ready(function()$("#loginModal").modal("show"););</script>';
<?php else

require 'function.php';
require 'includes/navbar.php';

?>

***
***
if session type is
set code goes here
***
***

<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>
<?php #close else ?>






php modal-dialog






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 8:08







Andy Roe

















asked Mar 21 at 23:49









Andy RoeAndy Roe

515




515












  • You didn't start a session with session_start();

    – user1334621
    Mar 21 at 23:56












  • Sorry, @catcon I appreciate your answer, this is included in another file. I will amend my question to reflect this

    – Andy Roe
    Mar 22 at 0:00











  • Thanks for your input Emma, this made no difference though

    – Andy Roe
    Mar 22 at 8:01

















  • You didn't start a session with session_start();

    – user1334621
    Mar 21 at 23:56












  • Sorry, @catcon I appreciate your answer, this is included in another file. I will amend my question to reflect this

    – Andy Roe
    Mar 22 at 0:00











  • Thanks for your input Emma, this made no difference though

    – Andy Roe
    Mar 22 at 8:01
















You didn't start a session with session_start();

– user1334621
Mar 21 at 23:56






You didn't start a session with session_start();

– user1334621
Mar 21 at 23:56














Sorry, @catcon I appreciate your answer, this is included in another file. I will amend my question to reflect this

– Andy Roe
Mar 22 at 0:00





Sorry, @catcon I appreciate your answer, this is included in another file. I will amend my question to reflect this

– Andy Roe
Mar 22 at 0:00













Thanks for your input Emma, this made no difference though

– Andy Roe
Mar 22 at 8:01





Thanks for your input Emma, this made no difference though

– Andy Roe
Mar 22 at 8:01












1 Answer
1






active

oldest

votes


















0














Where did you set $_SESSION['type'] ???



Please try this
index.php



<?php 

require 'database_connection.php';

if (!isset($_SESSION["type"])) ?>

<script> $('#loginModal').modal('show'); </script>";

<?php else

require 'includes/header.php';
?>

***
***
if session type is
set code goes here
***
***

<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>
<?php #close else ?>


database_connection.php



<?php

$connect = new PDO('mysql:host=localhost;dbname=continental3', 'root', 'password');
session_start();

?>





share|improve this answer























  • Still, no joy I am afraid Anandhukrishna VR. $_SESSION['type'] is set in login.php which works if I would like to login on a new page but not a modal window. You can visit login.php which will set the session type and all works fine using if (!isset($_SESSION["type"])) header("location:login.php");

    – Andy Roe
    Mar 22 at 8:21











  • So.. actually what your problem?

    – Anandhukrishna VR
    Mar 23 at 15:10











  • At the moment the code in my previous comment that works redirects to login.php page. I am trying to get a modal to show if session type is not set instead of redirect to the login page

    – Andy Roe
    Mar 23 at 15:52











  • replscr redirection code to if (!isset($_SESSION["type"])) //model code

    – Anandhukrishna VR
    Mar 25 at 3:41











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290873%2fshow-modal-if-not-logged-in%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Where did you set $_SESSION['type'] ???



Please try this
index.php



<?php 

require 'database_connection.php';

if (!isset($_SESSION["type"])) ?>

<script> $('#loginModal').modal('show'); </script>";

<?php else

require 'includes/header.php';
?>

***
***
if session type is
set code goes here
***
***

<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>
<?php #close else ?>


database_connection.php



<?php

$connect = new PDO('mysql:host=localhost;dbname=continental3', 'root', 'password');
session_start();

?>





share|improve this answer























  • Still, no joy I am afraid Anandhukrishna VR. $_SESSION['type'] is set in login.php which works if I would like to login on a new page but not a modal window. You can visit login.php which will set the session type and all works fine using if (!isset($_SESSION["type"])) header("location:login.php");

    – Andy Roe
    Mar 22 at 8:21











  • So.. actually what your problem?

    – Anandhukrishna VR
    Mar 23 at 15:10











  • At the moment the code in my previous comment that works redirects to login.php page. I am trying to get a modal to show if session type is not set instead of redirect to the login page

    – Andy Roe
    Mar 23 at 15:52











  • replscr redirection code to if (!isset($_SESSION["type"])) //model code

    – Anandhukrishna VR
    Mar 25 at 3:41















0














Where did you set $_SESSION['type'] ???



Please try this
index.php



<?php 

require 'database_connection.php';

if (!isset($_SESSION["type"])) ?>

<script> $('#loginModal').modal('show'); </script>";

<?php else

require 'includes/header.php';
?>

***
***
if session type is
set code goes here
***
***

<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>
<?php #close else ?>


database_connection.php



<?php

$connect = new PDO('mysql:host=localhost;dbname=continental3', 'root', 'password');
session_start();

?>





share|improve this answer























  • Still, no joy I am afraid Anandhukrishna VR. $_SESSION['type'] is set in login.php which works if I would like to login on a new page but not a modal window. You can visit login.php which will set the session type and all works fine using if (!isset($_SESSION["type"])) header("location:login.php");

    – Andy Roe
    Mar 22 at 8:21











  • So.. actually what your problem?

    – Anandhukrishna VR
    Mar 23 at 15:10











  • At the moment the code in my previous comment that works redirects to login.php page. I am trying to get a modal to show if session type is not set instead of redirect to the login page

    – Andy Roe
    Mar 23 at 15:52











  • replscr redirection code to if (!isset($_SESSION["type"])) //model code

    – Anandhukrishna VR
    Mar 25 at 3:41













0












0








0







Where did you set $_SESSION['type'] ???



Please try this
index.php



<?php 

require 'database_connection.php';

if (!isset($_SESSION["type"])) ?>

<script> $('#loginModal').modal('show'); </script>";

<?php else

require 'includes/header.php';
?>

***
***
if session type is
set code goes here
***
***

<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>
<?php #close else ?>


database_connection.php



<?php

$connect = new PDO('mysql:host=localhost;dbname=continental3', 'root', 'password');
session_start();

?>





share|improve this answer













Where did you set $_SESSION['type'] ???



Please try this
index.php



<?php 

require 'database_connection.php';

if (!isset($_SESSION["type"])) ?>

<script> $('#loginModal').modal('show'); </script>";

<?php else

require 'includes/header.php';
?>

***
***
if session type is
set code goes here
***
***

<div id="loginModal" class="modal fade">
<div class="modal-dialog">
<form method="post" id="product_form">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"><i class="fa fa-plus"></i> Add Product</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<div class="modal-body">
<div class="form-group">
<label>Stock Code</label>
<input type="text" name="product_name" id="product_name" class="form-control" required disabled />
</div>
<div class="form-group">
<label name="category_label" id="category_label">Category</label>
<select name="category_id" id="category_id" class="form-control" required>
<option value="">Select Category</option>
<?php echo fill_category_list($connect);?>
</select>
</div>
<div class="form-group">
<label>Enter Product Quantity</label>
<div class="input-group">
<input type="text" name="product_quantity" id="product_quantity" class="form-control" required pattern="[+-]?([0-9]*[.])?[0-9]+" placeholder="Enter Qty" />
<span class="input-group-addon">
<select class="form-control" name="product_unit" id="product_unit" required disabled>
<option value="Box">Boxes</option>
</select>
</span>
</div>
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="product_location" id="product_location" class="form-control" required disabled />
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="product_id" id="product_id" />
<input type="hidden" name="btn_action" id="btn_action" />
<input type="submit" name="action" id="action" class="btn btn-success" value="Add" />
</div>
</div>
</form>
</div>
</div>
<?php #close else ?>


database_connection.php



<?php

$connect = new PDO('mysql:host=localhost;dbname=continental3', 'root', 'password');
session_start();

?>






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 22 at 3:30









Anandhukrishna VRAnandhukrishna VR

5413




5413












  • Still, no joy I am afraid Anandhukrishna VR. $_SESSION['type'] is set in login.php which works if I would like to login on a new page but not a modal window. You can visit login.php which will set the session type and all works fine using if (!isset($_SESSION["type"])) header("location:login.php");

    – Andy Roe
    Mar 22 at 8:21











  • So.. actually what your problem?

    – Anandhukrishna VR
    Mar 23 at 15:10











  • At the moment the code in my previous comment that works redirects to login.php page. I am trying to get a modal to show if session type is not set instead of redirect to the login page

    – Andy Roe
    Mar 23 at 15:52











  • replscr redirection code to if (!isset($_SESSION["type"])) //model code

    – Anandhukrishna VR
    Mar 25 at 3:41

















  • Still, no joy I am afraid Anandhukrishna VR. $_SESSION['type'] is set in login.php which works if I would like to login on a new page but not a modal window. You can visit login.php which will set the session type and all works fine using if (!isset($_SESSION["type"])) header("location:login.php");

    – Andy Roe
    Mar 22 at 8:21











  • So.. actually what your problem?

    – Anandhukrishna VR
    Mar 23 at 15:10











  • At the moment the code in my previous comment that works redirects to login.php page. I am trying to get a modal to show if session type is not set instead of redirect to the login page

    – Andy Roe
    Mar 23 at 15:52











  • replscr redirection code to if (!isset($_SESSION["type"])) //model code

    – Anandhukrishna VR
    Mar 25 at 3:41
















Still, no joy I am afraid Anandhukrishna VR. $_SESSION['type'] is set in login.php which works if I would like to login on a new page but not a modal window. You can visit login.php which will set the session type and all works fine using if (!isset($_SESSION["type"])) header("location:login.php");

– Andy Roe
Mar 22 at 8:21





Still, no joy I am afraid Anandhukrishna VR. $_SESSION['type'] is set in login.php which works if I would like to login on a new page but not a modal window. You can visit login.php which will set the session type and all works fine using if (!isset($_SESSION["type"])) header("location:login.php");

– Andy Roe
Mar 22 at 8:21













So.. actually what your problem?

– Anandhukrishna VR
Mar 23 at 15:10





So.. actually what your problem?

– Anandhukrishna VR
Mar 23 at 15:10













At the moment the code in my previous comment that works redirects to login.php page. I am trying to get a modal to show if session type is not set instead of redirect to the login page

– Andy Roe
Mar 23 at 15:52





At the moment the code in my previous comment that works redirects to login.php page. I am trying to get a modal to show if session type is not set instead of redirect to the login page

– Andy Roe
Mar 23 at 15:52













replscr redirection code to if (!isset($_SESSION["type"])) //model code

– Anandhukrishna VR
Mar 25 at 3:41





replscr redirection code to if (!isset($_SESSION["type"])) //model code

– Anandhukrishna VR
Mar 25 at 3:41



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290873%2fshow-modal-if-not-logged-in%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript